Image encoding/decoding method and device, and recording medium storing bitstream

ABSTRACT

An image encoding/decoding method and apparatus for performing template matching-based intra prediction are provided. An image decoding method may comprise deriving a first intra-prediction mode for a current block, generating a first intra-prediction block corresponding to the first intra-prediction mode, deriving a second intra-prediction mode for the current block, generating a second intra-prediction block corresponding to the second intra-prediction mode, and generating a final intra-prediction block by using a weighted sum of the first intra-prediction block and the second intra-prediction block.

TECHNICAL FIELD

The present invention relates to a method and apparatus forencoding/decoding an image and a recording medium storing a bitstream.Particularly, the present invention relates to a method and apparatusfor encoding/decoding an image using intra prediction and a recordingmedium storing a bitstream generated by an image encodingmethod/apparatus of the present invention.

BACKGROUND ART

Recently, demands for high-resolution and high-quality images such ashigh definition (HD) images and ultra high definition (UHD) images, haveincreased in various application fields. However, higher resolution andquality image data has increasing amounts of data in comparison withconventional image data. Therefore, when transmitting image data byusing a medium such as conventional wired and wireless broadbandnetworks, or when storing image data by using a conventional storagemedium, costs of transmitting and storing increase. In order to solvethese problems occurring with an increase in resolution and quality ofimage data, high-efficiency image encoding/decoding techniques arerequired for higher-resolution and higher-quality images.

Image compression technology includes various techniques, including: aninter-prediction technique of predicting a pixel value included in acurrent picture from a previous or subsequent picture of the currentpicture; an intra-prediction technique of predicting a pixel valueincluded in a current picture by using pixel information in the currentpicture; a transform and quantization technique for compressing energyof a residual signal; an entropy encoding technique of assigning a shortcode to a value with a high appearance frequency and assigning a longcode to a value with a low appearance frequency; etc. Image data may beeffectively compressed by using such image compression technology, andmay be transmitted or stored.

Intra-prediction is a prediction technique that allows only spatialreference and refers to a method of predicting a current block byreferring to samples that have already been reconstructed around a blockto be currently encoded. Neighboring reference samples referred to inthe intra-prediction are not a brightness value of the original videobut a brightness value of a video reconstructed by prediction andrestoration before post-filtering is applied. Since the neighboringreference samples have been previously encoded and restored, they can beused as reference samples in the encoder and decoder.

Intra-prediction is conceptually effective only in a flat area withcontinuity with respect to the surrounding reference signal and an areawith a constant directionality, in which the area withoutcharacteristics in a video has significantly lower encoding efficiencythan inter-prediction. Especially, in the video encoding, since thevideo must be encoded only using intra-prediction for the first picture,random access, and error robustness, there is an increased need for amethod of enhancing encoding efficiency of the intra-prediction.

DISCLOSURE Technical Problem

An object of the present invention is to provide a method and apparatusfor encoding and decoding an image to enhance compression efficiency.

Another object of the present invention is to provide a method andapparatus for encoding and decoding an image using intra prediction toenhance compression efficiency.

Another object of the present invention is to provide a recording mediumstoring a bitstream generated by an image encoding method/apparatus ofthe present invention.

Technical Solution

A method of decoding a video according to an embodiment of the presentinvention may comprise deriving a first intra-prediction mode for acurrent block, generating a first intra-prediction block correspondingto the first intra-prediction mode, deriving a second intra-predictionmode for the current block, generating a second intra-prediction blockcorresponding to the second intra-prediction mode, and generating afinal intra-prediction block by using a weighted sum of the firstintra-prediction block and the second intra-prediction block.

In the method of decoding a video according to the present invention,the first intra-prediction mode may be derived on the basis of at leastone candidate mode included in a MPM list of the current block.

In the method of decoding a video according to the present invention,the first intra-prediction mode may be derived on the basis ofintra-prediction modes of one or more neighboring blocks to the currentblock.

In the method of decoding a video according to the present invention,the second intra-prediction mode may be one mode derived from candidatemodes included in a MPM list of the current block.

In the method of decoding a video according to the present invention,the deriving of the second intra-prediction mode may include generatingcandidate intra-prediction blocks corresponding to the candidate modes,calculating a matching degree between each of the candidateintra-prediction blocks and the first intra-prediction block, andderiving a candidate mode for a candidate intra-prediction block havingthe highest matching degree among the candidate intra-prediction blocks,as the second intra-prediction mode.

In the method of decoding a video according to the present invention,the matching degree may be calculated using a sum of absolute difference(SAD) or a sum of absolute transformed difference (SATD), and thecandidate intra-prediction block having the highest matching degree maybe a block with the SAD or the SATD being the smallest.

In the method of decoding a video according to the present invention,the generating of the candidate intra-prediction blocks and thecalculating of the matching degree may be skipped for a same mode as thefirst intra-prediction mode among the candidate modes.

In the method of decoding a video according to the present invention, aweight for the first intra-prediction block or the secondintra-prediction block corresponding to the first intra-prediction modeor the second intra-prediction mode that are same as a predeterminedmode may be higher than a weight for an intra-prediction blockcorresponding to a mode other than the predetermined mode.

In the method of decoding a video according to the present invention,the predetermined mode may be a first candidate mode in the MPM list.

In the method of decoding a video according to the present invention,when the number of the second intra-prediction modes and the secondintra-prediction blocks corresponding thereto is n (n is an integer of 2or more), n candidate modes in order of decreasing matching degree maybe derived as the second intra-prediction modes.

A method of encoding a video according to another embodiment of thepresent invention may comprise deriving a first intra-prediction modefor a current block, generating a first intra-prediction blockcorresponding to the first intra-prediction mode, deriving a secondintra-prediction mode for the current block, generating a secondintra-prediction block corresponding to the second intra-predictionmode, and generating a final intra-prediction block by using a weightedsum of the first intra-prediction block and the second intra-predictionblock.

In the method of encoding a video according to the present invention,the first intra-prediction mode may be derived on the basis of at leastone candidate mode included in a MPM list of the current block.

In the method of encoding a video according to the present invention,the first intra-prediction mode may be derived on the basis ofintra-prediction modes of one or more neighboring blocks to the currentblock.

In the method of encoding a video according to the present invention,the second intra-prediction mode may be one mode derived from candidatemodes included in a MPM list of the current block.

In the method of encoding a video according to the present invention,the deriving of the second intra-prediction mode may include generatingcandidate intra-prediction blocks corresponding to the candidate modes,calculating a matching degree between each of the candidateintra-prediction blocks and the first intra-prediction block, andderiving a candidate mode for a candidate intra-prediction block havingthe highest matching degree among the candidate intra-prediction blocks,as the second intra-prediction mode.

In the method of encoding a video according to the present invention,the matching degree may be calculated using a sum of absolute difference(SAD) or a sum of absolute transformed difference (SATD), and thecandidate intra-prediction block having the highest matching degree maybe a block with the SAD or the SATD being the smallest.

In the method of encoding a video according to the present invention,the generating of the candidate intra-prediction blocks and thecalculating of the matching degree may be skipped for a same mode as thefirst intra-prediction mode among the candidate modes.

In the method of encoding a video according to the present invention, aweight for the first intra-prediction block or the secondintra-prediction block corresponding to the first intra-prediction modeor the second intra-prediction mode that are same as a predeterminedmode may be higher than a weight for an intra-prediction blockcorresponding to a mode other than the predetermined mode.

In the method of encoding a video according to the present invention,when the number of the second intra-prediction modes and the secondintra-prediction blocks corresponding thereto is n (n is an integer of 2or more), n candidate modes in order of decreasing matching degree maybe derived as the second intra-prediction modes.

A computer readable recording medium according to another embodiment ofthe present invention may store a bitstream generated by an imageencoding method according to the present invention.

Advantageous Effects

According to the present invention, a method and apparatus for encodingand decoding an image to enhance compression efficiency may be provided.

According to the present invention, a method and apparatus for encodingand decoding an image using intra prediction to enhance compressionefficiency may be provided.

According to the present invention, a recording medium storing abitstream generated by an image encoding method/apparatus of the presentinvention may be provided.

DESCRIPTION OF DRAWINGS

FIG. 1 is a block diagram showing configurations of an encodingapparatus according to an embodiment of the present invention.

FIG. 2 is a block diagram showing configurations of a decoding apparatusaccording to an embodiment of the present invention.

FIG. 3 is a view schematically showing a partition structure of an imagewhen encoding and decoding the image.

FIG. 4 is a view for explaining an embodiment of a process of intraprediction.

FIG. 5 is a view for explaining an embodiment of a process of interprediction.

FIG. 6 is a view for explaining a process of transformation andquantization.

FIG. 7 is a diagram illustrating various embodiments for dividing oneblock into a plurality of blocks.

FIG. 8 is a diagram illustrating an embodiment in which one block isdivided by performing a binary-tree after quad-tree division andinformation on whether or not division is performed and/or a type ofdivision is signaled.

FIG. 9 is a diagram illustrating various embodiments of dividing acurrent block into two sub-blocks.

FIG. 10 is a view showing intra-prediction according to the presentinvention.

FIG. 11 is a diagram illustrating spatial neighboring blocks of acurrent block used when configuring an MPM list.

FIG. 12 is a view illustrating an embodiment for rearranging candidatemodes in the MPM list.

FIG. 13 is an exemplary diagram illustrating the relationship between aluma block and a chroma block.

FIG. 14 is a diagram for describing a plurality of reconstructed samplelines.

FIG. 15 is a diagram for describing a process of replacing anunavailable sample with an available sample.

FIG. 16 illustrates various filter shapes.

FIG. 17 is a diagram for describing intra prediction according to theshapes of the current block.

FIG. 18 is a diagram for describing neighboring samples of a currentblock used to derive the parameters of the models.

FIG. 19 is an exemplary diagram illustrating a process of restructuringa color component block.

FIG. 20 is a diagram illustrating an embodiment performing restructuringby using a plurality of upper-side reference sample lines and/or aplurality of left-side reference sample lines.

FIG. 21 is an exemplary diagram illustrating reference samples used forthe restructuring in accordance with an intra prediction mode or acoding parameter of a corresponding block.

FIG. 22 is a diagram illustrating an exemplary restructured first colorcomponent corresponding block when a second color component predictiontarget block is a 4×4 block.

FIG. 23 is a diagram illustrating a sample of a first color componentand a sample of a second color component.

FIG. 24 is a diagram illustrating an embodiment for generating atemplate.

FIG. 25 is a diagram illustrating an embodiment for generating atemplate matching-based intermediate intra-prediction block on the basisof the MPM list.

FIG. 26 is a view illustrating an embodiment for generating a finalintra-prediction block using a template and one intermediateintra-prediction block.

FIG. 27 is a diagram illustrating an embodiment in which a finalintra-frame prediction block is generated using the template and aplurality of intermediate intra-prediction blocks.

FIG. 28 is a diagram illustrating a method of scanning a transformcoefficient.

MODE FOR INVENTION

A variety of modifications may be made to the present invention andthere are various embodiments of the present invention, examples ofwhich will now be provided with reference to drawings and described indetail. However, the present invention is not limited thereto, althoughthe exemplary embodiments can be construed as including allmodifications, equivalents, or substitutes in a technical concept and atechnical scope of the present invention. The similar reference numeralsrefer to the same or similar functions in various aspects. In thedrawings, the shapes and dimensions of elements may be exaggerated forclarity. In the following detailed description of the present invention,references are made to the accompanying drawings that show, by way ofillustration, specific embodiments in which the invention may bepracticed. These embodiments are described in sufficient detail toenable those skilled in the art to implement the present disclosure. Itshould be understood that various embodiments of the present disclosure,although different, are not necessarily mutually exclusive. For example,specific features, structures, and characteristics described herein, inconnection with one embodiment, may be implemented within otherembodiments without departing from the spirit and scope of the presentdisclosure. In addition, it should be understood that the location orarrangement of individual elements within each disclosed embodiment maybe modified without departing from the spirit and scope of the presentdisclosure. The following detailed description is, therefore, not to betaken in a limiting sense, and the scope of the present disclosure isdefined only by the appended claims, appropriately interpreted, alongwith the full range of equivalents to what the claims claim.

Terms used in the specification, ‘first’, ‘second’, etc. can be used todescribe various components, but the components are not to be construedas being limited to the terms. The terms are only used to differentiateone component from other components. For example, the ‘first’ componentmay be named the ‘second’ component without departing from the scope ofthe present invention, and the ‘second’ component may also be similarlynamed the ‘first’ component. The term ‘and/or’ includes a combination ofa plurality of items or any one of a plurality of terms.

It will be understood that when an element is simply referred to asbeing ‘connected to’ or ‘coupled to’ another element without being‘directly connected to’ or ‘directly coupled to’ another element in thepresent description, it may be ‘directly connected to’ or ‘directlycoupled to’ another element or be connected to or coupled to anotherelement, having the other element intervening therebetween. In contrast,it should be understood that when an element is referred to as being“directly coupled” or “directly connected” to another element, there areno intervening elements present.

Furthermore, constitutional parts shown in the embodiments of thepresent invention are independently shown so as to representcharacteristic functions different from each other. Thus, it does notmean that each constitutional part is constituted in a constitutionalunit of separated hardware or software. In other words, eachconstitutional part includes each of enumerated constitutional parts forconvenience. Thus, at least two constitutional parts of eachconstitutional part may be combined to form one constitutional part orone constitutional part may be divided into a plurality ofconstitutional parts to perform each function. The embodiment where eachconstitutional part is combined and the embodiment where oneconstitutional part is divided are also included in the scope of thepresent invention, if not departing from the essence of the presentinvention.

The terms used in the present specification are merely used to describeparticular embodiments, and are not intended to limit the presentinvention. An expression used in the singular encompasses the expressionof the plural, unless it has a clearly different meaning in the context.In the present specification, it is to be understood that terms such as“including”, “having”, etc. are intended to indicate the existence ofthe features, numbers, steps, actions, elements, parts, or combinationsthereof disclosed in the specification, and are not intended to precludethe possibility that one or more other features, numbers, steps,actions, elements, parts, or combinations thereof may exist or may beadded. In other words, when a specific element is referred to as being“included”, elements other than the corresponding element are notexcluded, but additional elements may be included in embodiments of thepresent invention or the scope of the present invention.

In addition, some of constituents may not be indispensable constituentsperforming essential functions of the present invention but be selectiveconstituents improving only performance thereof. The present inventionmay be implemented by including only the indispensable constitutionalparts for implementing the essence of the present invention except theconstituents used in improving performance. The structure including onlythe indispensable constituents except the selective constituents used inimproving only performance is also included in the scope of the presentinvention.

Hereinafter, embodiments of the present invention will be described indetail with reference to the accompanying drawings. In describingexemplary embodiments of the present invention, well-known functions orconstructions will not be described in detail since they mayunnecessarily obscure the understanding of the present invention. Thesame constituent elements in the drawings are denoted by the samereference numerals, and a repeated description of the same elements willbe omitted.

Hereinafter, an image may mean a picture configuring a video, or maymean the video itself. For example, “encoding or decoding or both of animage” may mean “encoding or decoding or both of a moving picture”, andmay mean “encoding or decoding or both of one image among images of amoving picture.”

Hereinafter, terms “moving picture” and “video” may be used as the samemeaning and be replaced with each other.

Hereinafter, a target image may be an encoding target image which is atarget of encoding and/or a decoding target image which is a target ofdecoding. Also, a target image may be an input image inputted to anencoding apparatus, and an input image inputted to a decoding apparatus.Here, a target image may have the same meaning with the current image.

Hereinafter, terms “image”, “picture, “frame” and “screen” may be usedas the same meaning and be replaced with each other.

Hereinafter, a target block may be an encoding target block which is atarget of encoding and/or a decoding target block which is a target ofdecoding. Also, a target block may be the current block which is atarget of current encoding and/or decoding. For example, terms “targetblock” and “current block” may be used as the same meaning and bereplaced with each other.

Hereinafter, terms “block” and “unit” may be used as the same meaningand be replaced with each other. Or a “block” may represent a specificunit.

Hereinafter, terms “region” and “segment” may be replaced with eachother.

Hereinafter, a specific signal may be a signal representing a specificblock. For example, an original signal may be a signal representing atarget block. A prediction signal may be a signal representing aprediction block. A residual signal may be a signal representing aresidual block.

In embodiments, each of specific information, data, flag, index, elementand attribute, etc. may have a value. A value of information, data,flag, index, element and attribute equal to “0” may represent a logicalfalse or the first predefined value. In other words, a value “0”, afalse, a logical false and the first predefined value may be replacedwith each other. A value of information, data, flag, index, element andattribute equal to “1” may represent a logical true or the secondpredefined value. In other words, a value “1”, a true, a logical trueand the second predefined value may be replaced with each other.

When a variable i or j is used for representing a column, a row or anindex, a value of i may be an integer equal to or greater than 0, orequal to or greater than 1. That is, the column, the row, the index,etc. may be counted from 0 or may be counted from 1.

Description of Terms

Encoder: means an apparatus performing encoding. That is, means anencoding apparatus.

Decoder: means an apparatus performing decoding. That is, means andecoding apparatus.

Block: is an M×N array of a sample. Herein, M and N may mean positiveintegers, and the block may mean a sample array of a two-dimensionalform. The block may refer to a unit. A current block my mean an encodingtarget block that becomes a target when encoding, or a decoding targetblock that becomes a target when decoding. In addition, the currentblock may be at least one of an encode block, a prediction block, aresidual block, and a transform block.

Sample: is a basic unit constituting a block. It may be expressed as avalue from 0 to 2^(Bd)−1 according to a bit depth (Bd). In the presentinvention, the sample may be used as a meaning of a pixel. That is, asample, a pel, a pixel may have the same meaning with each other.

Unit: may refer to an encoding and decoding unit. When encoding anddecoding an image, the unit may be a region generated by partitioning asingle image. In addition, the unit may mean a subdivided unit when asingle image is partitioned into subdivided units during encoding ordecoding. That is, an image may be partitioned into a plurality ofunits. When encoding and decoding an image, a predetermined process foreach unit may be performed. A single unit may be partitioned intosub-units that have sizes smaller than the size of the unit. Dependingon functions, the unit may mean a block, a macroblock, a coding treeunit, a code tree block, a coding unit, a coding block), a predictionunit, a prediction block, a residual unit), a residual block, atransform unit, a transform block, etc. In addition, in order todistinguish a unit from a block, the unit may include a luma componentblock, a chroma component block associated with the luma componentblock, and a syntax element of each color component block. The unit mayhave various sizes and forms, and particularly, the form of the unit maybe a two-dimensional geometrical figure such as a square shape, arectangular shape, a trapezoid shape, a triangular shape, a pentagonalshape, etc. In addition, unit information may include at least one of aunit type indicating the coding unit, the prediction unit, the transformunit, etc., and a unit size, a unit depth, a sequence of encoding anddecoding of a unit, etc.

Coding Tree Unit: is configured with a single coding tree block of aluma component Y, and two coding tree blocks related to chromacomponents Cb and Cr. In addition, it may mean that including the blocksand a syntax element of each block. Each coding tree unit may bepartitioned by using at least one of a quad-tree partitioning method, abinary-tree partitioning method, a ternary-tree partitioning method,etc. to configure a lower unit such as coding unit, prediction unit,transform unit, etc. It may be used as a term for designating a sampleblock that becomes a process unit when encoding/decoding an image as aninput image. Here, a quad-tree may mean a quarternary-tree.

Coding Tree Block: may be used as a term for designating any one of a Ycoding tree block, Cb coding tree block, and Cr coding tree block.

Neighbor Block: may mean a block adjacent to a current block. The blockadjacent to the current block may mean a block that comes into contactwith a boundary of the current block, or a block positioned within apredetermined distance from the current block. The neighbor block maymean a block adjacent to a vertex of the current block. Herein, theblock adjacent to the vertex of the current block may mean a blockvertically adjacent to a neighbor block that is horizontally adjacent tothe current block, or a block horizontally adjacent to a neighbor blockthat is vertically adjacent to the current block.

Reconstructed Neighbor block: may mean a neighbor block adjacent to acurrent block and which has been already spatially/temporally encoded ordecoded. Herein, the reconstructed neighbor block may mean areconstructed neighbor unit. A reconstructed spatial neighbor block maybe a block within a current picture and which has been alreadyreconstructed through encoding or decoding or both. A reconstructedtemporal neighbor block is a block at a corresponding position as thecurrent block of the current picture within a reference image, or aneighbor block thereof.

Unit Depth: may mean a partitioned degree of a unit. In a treestructure, the highest node (Root Node) may correspond to the first unitwhich is not partitioned. Also, the highest node may have the leastdepth value. In this case, the highest node may have a depth of level 0.A node having a depth of level 1 may represent a unit generated bypartitioning once the first unit. A node having a depth of level 2 mayrepresent a unit generated by partitioning twice the first unit. A nodehaving a depth of level n may represent a unit generated by partitioningn-times the first unit. A Leaf Node may be the lowest node and a nodewhich cannot be partitioned further. A depth of a Leaf Node may be themaximum level. For example, a predefined value of the maximum level maybe 3. A depth of a root node may be the lowest and a depth of a leafnode may be the deepest. In addition, when a unit is expressed as a treestructure, a level in which a unit is present may mean a unit depth.

Bitstream: may mean a bitstream including encoding image information.

Parameter Set: corresponds to header information among a configurationwithin a bitstream. At least one of a video parameter set, a sequenceparameter set, a picture parameter set, and an adaptation parameter setmay be included in a parameter set. In addition, a parameter set mayinclude a slice header, and tile header information.

Parsing: may mean determination of a value of a syntax element byperforming entropy decoding, or may mean the entropy decoding itself.

Symbol: may mean at least one of a syntax element, a coding parameter,and a transform coefficient value of an encoding/decoding target unit.In addition, the symbol may mean an entropy encoding target or anentropy decoding result.

Prediction Mode: may be information indicating a mode encoded/decodedwith intra prediction or a mode encoded/decoded with inter prediction.

Prediction Unit: may mean a basic unit when performing prediction suchas inter-prediction, intra-prediction, inter-compensation,intra-compensation, and motion compensation. A single prediction unitmay be partitioned into a plurality of partitions having a smaller size,or may be partitioned into a plurality of lower prediction units. Aplurality of partitions may be a basic unit in performing prediction orcompensation. A partition which is generated by dividing a predictionunit may also be a prediction unit.

Prediction Unit Partition: may mean a form obtained by partitioning aprediction unit.

Reference Picture List: may mean a list including one or more referencepictures used for inter-picture prediction or motion compensation. LC(List Combined), L0 (List 0), L1 (List 1), L2 (List 2), L3 (List 3) andthe like are types of reference picture lists. One or more referencepicture lists may be used for inter-picture prediction.

Inter-picture prediction Indicator: may mean an inter-picture predictiondirection (uni-directional prediction, bi-directional prediction, andthe like) of a current block. Alternatively, the inter-pictureprediction indicator may mean the number of reference pictures used togenerate a prediction block of a current block. Further alternatively,the inter-picture prediction indicator may mean the number of predictionblocks used to perform inter-picture prediction or motion compensationwith respect to a current block.

Prediction list utilization flag: may represent whether a predictionblock is generated using at least one reference image included in aspecific reference picture list. An inter prediction indicator may bederived using a prediction list utilization flag, and reversely, aprediction list utilization flag may be derived using an interprediction indicator. For example, when a prediction list utilizationflag indicates a first value of “0”, it represents a prediction block isnot generated using a reference picture included in the correspondingreference picture list. When a prediction list utilization flagindicates a second value of “1”, it represents a prediction block isgenerated using a reference picture included in the correspondingreference picture list.

Reference Picture Index: may mean an index indicating a specificreference picture in a reference picture list.

Reference Picture: may mean a picture to which a specific block refersfor inter-picture prediction or motion compensation. Alternatively, areference picture may be a picture including a reference block referredto by a current block for inter prediction or motion compensation.Hereinafter, the term “reference picture” and “reference image” may beused as the same meaning and used interchangeably.

Motion Vector: is a two-dimensional vector used for inter-pictureprediction or motion compensation and may mean an offset between areference picture and an encoding/decoding target picture. For example,(mvX, mvY) may represent a motion vector, mvX may represent a horizontalcomponent, and mvY may represent a vertical component.

Search Range: may be a 2-dimensional region where search for a motionvector during inter prediction is performed. For example, a size of asearch range may be M×N. M and N may be a positive integer,respectively.

Motion Vector Candidate: may mean a block that becomes a predictioncandidate when predicting a motion vector, or a motion vector of theblock. A motion vector candidate may be listed in a motion vectorcandidate list.

Motion Vector Candidate List: may mean a list configured using one ormore motion vector candidates.

Motion Vector Candidate Index: means an indicator indicating a motionvector candidate in a motion vector candidate list. It is also referredto as an index of a motion vector predictor.

Motion Information: may mean information including a motion vector, areference picture index, an inter-picture prediction indicator, and atleast any one among reference picture list information, a referencepicture, a motion vector candidate, a motion vector candidate index, amerge candidate, and a merge index.

Merge Candidate List: may mean a list composed of merge candidates.

Merge Candidate: may mean a spatial merge candidate, a temporal mergecandidate, a combined merge candidate, a combined bi-prediction mergecandidate, a zero merge candidate, or the like. The merge candidate mayhave an inter-picture prediction indicator, a reference picture indexfor each list, and motion information such as a motion vector.

Merge Index: may mean an indicator indicating a merge candidate within amerge candidate list. The merge index may indicate a block used toderive a merge candidate, among reconstructed blocks spatially and/ortemporally adjacent to a current block. The merge index may indicate atleast one item in the motion information possessed by a merge candidate.

Transform Unit: may mean a basic unit when performing encoding/decodingsuch as transform, inverse-transform, quantization, dequantization,transform coefficient encoding/decoding of a residual signal. A singletransform unit may be partitioned into a plurality of lower-leveltransform units having a smaller size. Here,transformation/inverse-transformation may comprise at least one amongthe first transformation/the first inverse-transformation and the secondtransformation/the second inverse-transformation.

Scaling: may mean a process of multiplying a quantized level by afactor. A transform coefficient may be generated by scaling a quantizedlevel. The scaling also may be referred to as dequantization.

Quantization Parameter: may mean a value used when generating aquantized level using a transform coefficient during quantization. Thequantization parameter also may mean a value used when generating atransform coefficient by scaling a quantized level duringdequantization. The quantization parameter may be a value mapped on aquantization step size.

Delta Quantization Parameter: may mean a difference value between apredicted quantization parameter and a quantization parameter of anencoding/decoding target unit.

Scan: may mean a method of sequencing coefficients within a unit, ablock or a matrix. For example, changing a two-dimensional matrix ofcoefficients into a one-dimensional matrix may be referred to asscanning, and changing a one-dimensional matrix of coefficients into atwo-dimensional matrix may be referred to as scanning or inversescanning.

Transform Coefficient: may mean a coefficient value generated aftertransform is performed in an encoder. It may mean a coefficient valuegenerated after at least one of entropy decoding and dequantization isperformed in a decoder. A quantized level obtained by quantizing atransform coefficient or a residual signal, or a quantized transformcoefficient level also may fall within the meaning of the transformcoefficient.

Quantized Level: may mean a value generated by quantizing a transformcoefficient or a residual signal in an encoder. Alternatively, thequantized level may mean a value that is a dequantization target toundergo dequantization in a decoder. Similarly, a quantized transformcoefficient level that is a result of transform and quantization alsomay fall within the meaning of the quantized level.

Non-zero Transform Coefficient: may mean a transform coefficient havinga value other than zero, or a transform coefficient level or a quantizedlevel having a value other than zero.

Quantization Matrix: may mean a matrix used in a quantization process ora dequantization process performed to improve subjective or objectiveimage quality. The quantization matrix also may be referred to as ascaling list.

Quantization Matrix Coefficient: may mean each element within aquantization matrix. The quantization matrix coefficient also may bereferred to as a matrix coefficient.

Default Matrix: may mean a predetermined quantization matrixpreliminarily defined in an encoder or a decoder.

Non-default Matrix: may mean a quantization matrix that is notpreliminarily defined in an encoder or a decoder but is signaled by auser.

Statistic Value: a statistic value for at least one among a variable, anencoding parameter, a constant value, etc. which have a computablespecific value may be one or more among an average value, a weightedaverage value, a weighted sum value, the minimum value, the maximumvalue, the most frequent value, a median value, an interpolated value ofthe corresponding specific values.

FIG. 1 is a block diagram showing a configuration of an encodingapparatus according to an embodiment to which the present invention isapplied.

An encoding apparatus 100 may be an encoder, a video encoding apparatus,or an image encoding apparatus. A video may include at least one image.The encoding apparatus 100 may sequentially encode at least one image.

Referring to FIG. 1, the encoding apparatus 100 may include a motionprediction unit 111, a motion compensation unit 112, an intra-predictionunit 120, a switch 115, a subtractor 125, a transform unit 130, aquantization unit 140, an entropy encoding unit 150, a dequantizationunit 160, a inverse-transform unit 170, an adder 175, a filter unit 180,and a reference picture buffer 190.

The encoding apparatus 100 may perform encoding of an input image byusing an intra mode or an inter mode or both. In addition, encodingapparatus 100 may generate a bitstream including encoded informationthrough encoding the input image, and output the generated bitstream.The generated bitstream may be stored in a computer readable recordingmedium, or may be streamed through a wired/wireless transmission medium.When an intra mode is used as a prediction mode, the switch 115 may beswitched to an intra. Alternatively, when an inter mode is used as aprediction mode, the switch 115 may be switched to an inter mode.Herein, the intra mode may mean an intra-prediction mode, and the intermode may mean an inter-prediction mode. The encoding apparatus 100 maygenerate a prediction block for an input block of the input image. Inaddition, the encoding apparatus 100 may encode a residual block using aresidual of the input block and the prediction block after theprediction block being generated. The input image may be called as acurrent image that is a current encoding target. The input block may becalled as a current block that is current encoding target, or as anencoding target block.

When a prediction mode is an intra mode, the intra-prediction unit 120may use a sample of a block that has been already encoded/decoded and isadjacent to a current block as a reference sample. The intra-predictionunit 120 may perform spatial prediction for the current block by using areference sample, or generate prediction samples of an input block byperforming spatial prediction. Herein, the intra prediction may meanintra-prediction,

When a prediction mode is an inter mode, the motion prediction unit 111may retrieve a region that best matches with an input block from areference image when performing motion prediction, and deduce a motionvector by using the retrieved region. In this case, a search region maybe used as the region. The reference image may be stored in thereference picture buffer 190. Here, when encoding/decoding for thereference image is performed, it may be stored in the reference picturebuffer 190.

The motion compensation unit 112 may generate a prediction block byperforming motion compensation for the current block using a motionvector. Herein, inter-prediction may mean inter-prediction or motioncompensation.

When the value of the motion vector is not an integer, the motionprediction unit 111 and the motion compensation unit 112 may generatethe prediction block by applying an interpolation filter to a partialregion of the reference picture. In order to perform inter prediction ormotion compensation on a coding unit, it may be determined that whichmode among a skip mode, a merge mode, an advanced motion vectorprediction (AMVP) mode, and a current picture referring mode is used formotion prediction and motion compensation of a prediction unit includedin the corresponding coding unit. Then, inter prediction or motioncompensation may be differently performed depending on the determinedmode.

The subtractor 125 may generate a residual block by using a residual ofan input block and a prediction block. The residual block may be calledas a residual signal. The residual signal may mean a difference betweenan original signal and a prediction signal. In addition, the residualsignal may be a signal generated by transforming or quantizing, ortransforming and quantizing a difference between the original signal andthe prediction signal. The residual block may be a residual signal of ablock unit.

The transform unit 130 may generate a transform coefficient byperforming transform of a residual block, and output the generatedtransform coefficient. Herein, the transform coefficient may be acoefficient value generated by performing transform of the residualblock. When a transform skip mode is applied, the transform unit 130 mayskip transform of the residual block.

A quantized level may be generated by applying quantization to thetransform coefficient or to the residual signal. Hereinafter, thequantized level may be also called as a transform coefficient inembodiments.

The quantization unit 140 may generate a quantized level by quantizingthe transform coefficient or the residual signal according to aparameter, and output the generated quantized level. Herein, thequantization unit 140 may quantize the transform coefficient by using aquantization matrix.

The entropy encoding unit 150 may generate a bitstream by performingentropy encoding according to a probability distribution on valuescalculated by the quantization unit 140 or on coding parameter valuescalculated when performing encoding, and output the generated bitstream.The entropy encoding unit 150 may perform entropy encoding of sampleinformation of an image and information for decoding an image. Forexample, the information for decoding the image may include a syntaxelement.

When entropy encoding is applied, symbols are represented so that asmaller number of bits are assigned to a symbol having a high chance ofbeing generated and a larger number of bits are assigned to a symbolhaving a low chance of being generated, and thus, the size of bit streamfor symbols to be encoded may be decreased. The entropy encoding unit150 may use an encoding method for entropy encoding such as exponentialGolomb, context-adaptive variable length coding (CAVLC),context-adaptive binary arithmetic coding (CABAC), etc. For example, theentropy encoding unit 150 may perform entropy encoding by using avariable length coding/code (VLC) table. In addition, the entropyencoding unit 150 may deduce a binarization method of a target symboland a probability model of a target symbol/bin, and perform arithmeticcoding by using the deduced binarization method, and a context model.

In order to encode a transform coefficient level (quantized level), theentropy encoding unit 150 may change a two-dimensional block formcoefficient into a one-dimensional vector form by using a transformcoefficient scanning method.

A coding parameter may include information (flag, index, etc.) such assyntax element that is encoded in an encoder and signaled to a decoder,and information derived when performing encoding or decoding. The codingparameter may mean information required when encoding or decoding animage. For example, at least one value or a combination form of aunit/block size, a unit/block depth, unit/block partition information,unit/block shape, unit/block partition structure, whether to partitionof a quad-tree form, whether to partition of a binary-tree form, apartition direction of a binary-tree form (horizontal direction orvertical direction), a partition form of a binary-tree form (symmetricpartition or asymmetric partition), whether to partition of aternary-tree form, a partition direction of a ternary-tree form(horizontal direction or vertical direction), a partition form of aternary-tree form (symmetric partition or asymmetric partition), whetherto partition of a multi-type-tree form, a partition direction of amulti-type-tree form (horizontal direction or vertical direction), apartition form of a multi-type-tree form (symmetric partition orasymmetric partition), a partitioning tree of multi-type-tree form, aprediction mode (intra prediction or inter prediction), a lumaintra-prediction mode/direction, a chroma intra-predictionmode/direction, intra partition information, inter partitioninformation, a coding block partition flag, a prediction block partitionflag, a transform block partition flag, a reference sample filteringmethod, a reference sample filter tab, a reference sample filtercoefficient, a prediction block filtering method, a prediction blockfilter tap, a prediction block filter coefficient, a prediction blockboundary filtering method, a prediction block boundary filter tab, aprediction block boundary filter coefficient, an intra-prediction mode,an inter-prediction mode, motion information, a motion vector, a motionvector difference, a reference picture index, a inter-prediction angle,an inter-prediction indicator, a prediction list utilization flag, areference picture list, a reference picture, a motion vector predictorindex, a motion vector predictor candidate, a motion vector candidatelist, whether to use a merge mode, a merge index, a merge candidate, amerge candidate list, whether to use a skip mode, an interpolationfilter type, an interpolation filter tab, an interpolation filtercoefficient, a motion vector size, a presentation accuracy of a motionvector, a transform type, a transform size, information of whether ornot a primary (first) transform is used, information of whether or not asecondary transform is used, a primary transform index, a secondarytransform index, information of whether or not a residual signal ispresent, a coded block pattern, a coded block flag (CBF), a quantizationparameter, a quantization parameter residue, a quantization matrix,whether to apply an intra loop filter, an intra loop filter coefficient,an intra loop filter tab, an intra loop filter shape/form, whether toapply a deblocking filter, a deblocking filter coefficient, a deblockingfilter tab, a deblocking filter strength, a deblocking filtershape/form, whether to apply an adaptive sample offset, an adaptivesample offset value, an adaptive sample offset category, an adaptivesample offset type, whether to apply an adaptive loop filter, anadaptive loop filter coefficient, an adaptive loop filter tab, anadaptive loop filter shape/form, a binarization/inverse-binarizationmethod, a context model determining method, a context model updatingmethod, whether to perform a regular mode, whether to perform a bypassmode, a context bin, a bypass bin, a significant coefficient flag, alast significant coefficient flag, a coded flag for a unit of acoefficient group, a position of the last significant coefficient, aflag for whether a value of a coefficient is larger than 1, a flag forwhether a value of a coefficient is larger than 2, a flag for whether avalue of a coefficient is larger than 3, information on a remainingcoefficient value, a sign information, a reconstructed luma sample, areconstructed chroma sample, a residual luma sample, a residual chromasample, a luma transform coefficient, a chroma transform coefficient, aquantized luma level, a quantized chroma level, a transform coefficientlevel scanning method, a size of a motion vector search area at adecoder side, a shape of a motion vector search area at a decoder side,a number of time of a motion vector search at a decoder side,information on a CTU size, information on a minimum block size,information on a maximum block size, information on a maximum blockdepth, information on a minimum block depth, an imagedisplaying/outputting sequence, slice identification information, aslice type, slice partition information, tile identificationinformation, a tile type, tile partition information, a picture type, abit depth of an input sample, a bit depth of a reconstruction sample, abit depth of a residual sample, a bit depth of a transform coefficient,a bit depth of a quantized level, and information on a luma signal orinformation on a chroma signal may be included in the coding parameter.

Herein, signaling the flag or index may mean that a corresponding flagor index is entropy encoded and included in a bitstream by an encoder,and may mean that the corresponding flag or index is entropy decodedfrom a bitstream by a decoder.

When the encoding apparatus 100 performs encoding throughinter-prediction, an encoded current image may be used as a referenceimage for another image that is processed afterwards. Accordingly, theencoding apparatus 100 may reconstruct or decode the encoded currentimage, or store the reconstructed or decoded image as a reference imagein reference picture buffer 190.

A quantized level may be dequantized in the dequantization unit 160, ormay be inverse-transformed in the inverse-transform unit 170. Adequantized or inverse-transformed coefficient or both may be added witha prediction block by the adder 175. By adding the dequantized orinverse-transformed coefficient or both with the prediction block, areconstructed block may be generated. Herein, the dequantized orinverse-transformed coefficient or both may mean a coefficient on whichat least one of dequantization and inverse-transform is performed, andmay mean a reconstructed residual block.

A reconstructed block may pass through the filter unit 180. The filterunit 180 may apply at least one of a deblocking filter, a sampleadaptive offset (SAO), and an adaptive loop filter (ALF) to areconstructed sample, a reconstructed block or a reconstructed image.The filter unit 180 may be called as an in-loop filter.

The deblocking filter may remove block distortion generated inboundaries between blocks. In order to determine whether or not to applya deblocking filter, whether or not to apply a deblocking filter to acurrent block may be determined based samples included in several rowsor columns which are included in the block. When a deblocking filter isapplied to a block, another filter may be applied according to arequired deblocking filtering strength.

In order to compensate an encoding error, a proper offset value may beadded to a sample value by using a sample adaptive offset. The sampleadaptive offset may correct an offset of a deblocked image from anoriginal image by a sample unit. A method of partitioning samples of animage into a predetermined number of regions, determining a region towhich an offset is applied, and applying the offset to the determinedregion, or a method of applying an offset in consideration of edgeinformation on each sample may be used.

The adaptive loop filter may perform filtering based on a comparisonresult of the filtered reconstructed image and the original image.Samples included in an image may be partitioned into predeterminedgroups, a filter to be applied to each group may be determined, anddifferential filtering may be performed for each group. Information ofwhether or not to apply the ALF may be signaled by coding units (CUs),and a form and coefficient of the ALF to be applied to each block mayvary.

The reconstructed block or the reconstructed image having passed throughthe filter unit 180 may be stored in the reference picture buffer 190. Areconstructed block processed by the filter unit 180 may be a part of areference image. That is, a reference image is a reconstructed imagecomposed of reconstructed blocks processed by the filter unit 180. Thestored reference image may be used later in inter prediction or motioncompensation.

FIG. 2 is a block diagram showing a configuration of a decodingapparatus according to an embodiment and to which the present inventionis applied.

A decoding apparatus 200 may a decoder, a video decoding apparatus, oran image decoding apparatus.

Referring to FIG. 2, the decoding apparatus 200 may include an entropydecoding unit 210, a dequantization unit 220, a inverse-transform unit230, an intra-prediction unit 240, a motion compensation unit 250, anadder 255, a filter unit 260, and a reference picture buffer 270.

The decoding apparatus 200 may receive a bitstream output from theencoding apparatus 100. The decoding apparatus 200 may receive abitstream stored in a computer readable recording medium, or may receivea bitstream that is streamed through a wired/wireless transmissionmedium. The decoding apparatus 200 may decode the bitstream by using anintra mode or an inter mode. In addition, the decoding apparatus 200 maygenerate a reconstructed image generated through decoding or a decodedimage, and output the reconstructed image or decoded image.

When a prediction mode used when decoding is an intra mode, a switch maybe switched to an intra. Alternatively, when a prediction mode used whendecoding is an inter mode, a switch may be switched to an inter mode.

The decoding apparatus 200 may obtain a reconstructed residual block bydecoding the input bitstream, and generate a prediction block. When thereconstructed residual block and the prediction block are obtained, thedecoding apparatus 200 may generate a reconstructed block that becomes adecoding target by adding the reconstructed residual block with theprediction block. The decoding target block may be called a currentblock.

The entropy decoding unit 210 may generate symbols by entropy decodingthe bitstream according to a probability distribution. The generatedsymbols may include a symbol of a quantized level form. Herein, anentropy decoding method may be a inverse-process of the entropy encodingmethod described above.

In order to decode a transform coefficient level (quantized level), theentropy decoding unit 210 may change a one-directional vector formcoefficient into a two-dimensional block form by using a transformcoefficient scanning method.

A quantized level may be dequantized in the dequantization unit 220, orinverse-transformed in the inverse-transform unit 230. The quantizedlevel may be a result of dequantizing or inverse-transforming or both,and may be generated as a reconstructed residual block. Herein, thedequantization unit 220 may apply a quantization matrix to the quantizedlevel.

When an intra mode is used, the intra-prediction unit 240 may generate aprediction block by performing, for the current block, spatialprediction that uses a sample value of a block adjacent to a decodingtarget block and which has been already decoded.

When an inter mode is used, the motion compensation unit 250 maygenerate a prediction block by performing, for the current block, motioncompensation that uses a motion vector and a reference image stored inthe reference picture buffer 270.

The adder 225 may generate a reconstructed block by adding thereconstructed residual block with the prediction block. The filter unit260 may apply at least one of a deblocking filter, a sample adaptiveoffset, and an adaptive loop filter to the reconstructed block orreconstructed image. The filter unit 260 may output the reconstructedimage. The reconstructed block or reconstructed image may be stored inthe reference picture buffer 270 and used when performinginter-prediction. A reconstructed block processed by the filter unit 260may be a part of a reference image. That is, a reference image is areconstructed image composed of reconstructed blocks processed by thefilter unit 260. The stored reference image may be used later in interprediction or motion compensation.

FIG. 3 is a view schematically showing a partition structure of an imagewhen encoding and decoding the image. FIG. 3 schematically shows anexample of partitioning a single unit into a plurality of lower units.

In order to efficiently partition an image, when encoding and decoding,a coding unit (CU) may be used. The coding unit may be used as a basicunit when encoding/decoding the image. In addition, the coding unit maybe used as a unit for distinguishing an intra prediction mode and aninter prediction mode when encoding/decoding the image. The coding unitmay be a basic unit used for prediction, transform, quantization,inverse-transform, dequantization, or an encoding/decoding process of atransform coefficient.

Referring to FIG. 3, an image 300 is sequentially partitioned in alargest coding unit (LCU), and a LCU unit is determined as a partitionstructure. Herein, the LCU may be used in the same meaning as a codingtree unit (CTU). A unit partitioning may mean partitioning a blockassociated with to the unit. In block partition information, informationof a unit depth may be included. Depth information may represent anumber of times or a degree or both in which a unit is partitioned. Asingle unit may be partitioned into a plurality of lower level unitshierarchically associated with depth information based on a treestructure. In other words, a unit and a lower level unit generated bypartitioning the unit may correspond to a node and a child node of thenode, respectively. Each of partitioned lower unit may have depthinformation. Depth information may be information representing a size ofa CU, and may be stored in each CU. Unit depth represents times and/ordegrees related to partitioning a unit. Therefore, partitioninginformation of a lower-level unit may comprise information on a size ofthe lower-level unit.

A partition structure may mean a distribution of a coding unit (CU)within a CTU 310. Such a distribution may be determined according towhether or not to partition a single CU into a plurality (positiveinteger equal to or greater than 2 including 2, 4, 8, 16, etc.) of CUs.A horizontal size and a vertical size of the CU generated bypartitioning may respectively be half of a horizontal size and avertical size of the CU before partitioning, or may respectively havesizes smaller than a horizontal size and a vertical size beforepartitioning according to a number of times of partitioning. The CU maybe recursively partitioned into a plurality of CUs. By the recursivepartitioning, at least one among a height and a width of a CU afterpartitioning may decrease comparing with at least one among a height anda width of a CU before partitioning. Partitioning of the CU may berecursively performed until to a predefined depth or predefined size.For example, a depth of a CTU may be 0, and a depth of a smallest codingunit (SCU) may be a predefined maximum depth. Herein, the CTU may be acoding unit having a maximum coding unit size, and the SCU may be acoding unit having a minimum coding unit size as described above.Partitioning is started from the CTU 310, a CU depth increases by 1 as ahorizontal size or a vertical size or both of the CU decreases bypartitioning. For example, for each depth, a CU which is not partitionedmay have a size of 2N×2N. Also, in case of a CU which is partitioned, aCU with a size of 2N×2N may be partitioned into four CUs with a size ofN×N. A size of N may decrease to half as a depth increase by 1.

In addition, information whether or not the CU is partitioned may berepresented by using partition information of the CU. The partitioninformation may be 1-bit information. All CUs, except for a SCU, mayinclude partition information. For example, when a value of partitioninformation is a first value, the CU may not be partitioned, when avalue of partition information is a second value, the CU may bepartitioned.

Referring to FIG. 3, a CTU having a depth 0 may be a 64×64 block. 0 maybe a minimum depth. A SCU having a depth 3 may be an 8×8 block. 3 may bea maximum depth. A CU of a 32×32 block and a 16×16 block may berespectively represented as a depth 1 and a depth 2.

For example, when a single coding unit is partitioned into four codingunits, a horizontal size and a vertical size of the four partitionedcoding units may be a half size of a horizontal and vertical size of theCU before being partitioned. In one embodiment, when a coding unithaving a 32×32 size is partitioned into four coding units, each of thefour partitioned coding units may have a 16×16 size. When a singlecoding unit is partitioned into four coding units, it may be called thatthe coding unit may be partitioned (quad-tree partitioned) into aquad-tree form.

For example, when a single coding unit is partitioned into two codingunits, a horizontal or vertical size of the two coding units may be ahalf of a horizontal or vertical size of the coding unit before beingpartitioned. For example, when a coding unit having a 32×32 size ispartitioned in a vertical direction, each of two partitioned codingunits may have a size of 16×32. For example, when a coding unit having asize of 8×32 is horizontally partitioned into two sub-coding units, eachof the two sub-coding units may have a size of 8×16. When a singlecoding unit is partitioned into two coding units, it may be called thatthe coding unit is partitioned (binary-tree partitioned) in abinary-tree form.

For example, when one coding unit is partitioned into three sub-codingunits, the horizontal or vertical size of the coding unit can bepartitioned with a ratio of 1:2:1, thereby producing three sub-codingunits whose horizontal or vertical sizes are in a ratio of 1:2:1. Forexample, when a coding unit having a size of 16×32 is horizontallypartitioned into three sub-coding units, the three sub-coding units mayhave sizes of 16×8, 16×16, and 16×8 respectively, in the order from theuppermost to the lowermost sub-coding unit. For example, when a codingunit having a size of 32×32 is vertically split into three sub-codingunits, the three sub-coding units may have sizes of 8×32, 16×32, and8×32, respectively in the order from the left to the right sub-codingunit. When one coding unit is partitioned into three sub-coding units,it can be said that the coding unit is ternary-tree partitioned orpartitioned by a ternary tree partition structure.

In FIG. 3, a coding tree unit (CTU) 320 is an example of a CTU to whicha quad tree partition structure, a binary tree partition structure, anda ternary tree partition structure are all applied.

As described above, in order to partition the CTU, at least one of aquad tree partition structure, a binary tree partition structure, and aternary tree partition structure may be applied. Various tree partitionstructures may be sequentially applied to the CTU, according to apredetermined priority order. For example, the quad tree partitionstructure may be preferentially applied to the CTU. A coding unit thatcannot be partitioned any longer using a quad tree partition structuremay correspond to a leaf node of a quad tree. A coding unitcorresponding to a leaf node of a quad tree may serve as a root node ofa binary and/or ternary tree partition structure. That is, a coding unitcorresponding to a leaf node of a quad tree may be further partitionedby a binary tree partition structure or a ternary tree partitionstructure, or may not be further partitioned. Therefore, by preventing acoding block that results from binary tree partitioning or ternary treepartitioning of a coding unit corresponding to a leaf node of a quadtree from undergoing further quad tree partitioning, block partitioningand/or signaling of partition information can be effectively performed.

The fact that a coding unit corresponding to a node of a quad tree ispartitioned may be signaled using quad partition information. The quadpartition information having a first value (e.g., “1”) may indicate thata current coding unit is partitioned by the quad tree partitionstructure. The quad partition information having a second value (e.g.,“0”) may indicate that a current coding unit is not partitioned by thequad tree partition structure. The quad partition information may be aflag having a predetermined length (e.g., one bit).

There may not be a priority between the binary tree partitioning and theternary tree partitioning. That is, a coding unit corresponding to aleaf node of a quad tree may further undergo arbitrary partitioningamong the binary tree partitioning and the ternary tree partitioning. Inaddition, a coding unit generated through the binary tree partitioningor the ternary tree partitioning may undergo a further binary treepartitioning or a further ternary tree partitioning, or may not befurther partitioned.

A tree structure in which there is no priority among the binary treepartitioning and the ternary tree partitioning is referred to as amulti-type tree structure. A coding unit corresponding to a leaf node ofa quad tree may serve as a root node of a multi-type tree. Whether topartition a coding unit which corresponds to a node of a multi-type treemay be signaled using at least one of multi-type tree partitionindication information, partition direction information, and partitiontree information. For partitioning of a coding unit corresponding to anode of a multi-type tree, the multi-type tree partition indicationinformation, the partition direction, and the partition tree informationmay be sequentially signaled.

The multi-type tree partition indication information having a firstvalue (e.g., “1”) may indicate that a current coding unit is to undergoa multi-type tree partitioning. The multi-type tree partition indicationinformation having a second value (e.g., “0”) may indicate that acurrent coding unit is not to undergo a multi-type tree partitioning.

When a coding unit corresponding to a node of a multi-type tree ispartitioned by a multi-type tree partition structure, the coding unitmay further include partition direction information. The partitiondirection information may indicate in which direction a current codingunit is to be partitioned for the multi-type tree partitioning. Thepartition direction information having a first value (e.g., “1”) mayindicate that a current coding unit is to be vertically partitioned. Thepartition direction information having a second value (e.g., “0”) mayindicate that a current coding unit is to be horizontally partitioned.

When a coding unit corresponding to a node of a multi-type tree ispartitioned by a multi-type tree partition structure, the current codingunit may further include partition tree information. The partition treeinformation may indicate a tree partition structure which is to be usedfor partitioning of a node of a multi-type tree. The partition treeinformation having a first value (e.g., “1”) may indicate that a currentcoding unit is to be partitioned by a binary tree partition structure.The partition tree information having a second value (e.g., “0”) mayindicate that a current coding unit is to be partitioned by a ternarytree partition structure.

The partition indication information, the partition tree information,and the partition direction information may each be a flag having apredetermined length (e.g., one bit).

At least any one of the quad-tree partition indication information, themulti-type tree partition indication information, the partitiondirection information, and the partition tree information may be entropyencoded/decoded. For the entropy-encoding/decoding of those types ofinformation, information on a neighboring coding unit adjacent to thecurrent coding unit may be used. For example, there is a highprobability that the partition type (the partitioned or non-partitioned,the partition tree, and/or the partition direction) of a leftneighboring coding unit and/or an upper neighboring coding unit of acurrent coding unit is similar to that of the current coding unit.Therefore, context information for entropy encoding/decoding of theinformation on the current coding unit may be derived from theinformation on the neighboring coding units. The information on theneighboring coding units may include at least any one of quad partitioninformation, multi-type tree partition indication information, partitiondirection information, and partition tree information.

As another example, among binary tree partitioning and ternary treepartitioning, binary tree partitioning may be preferentially performed.That is, a current coding unit may primarily undergo binary treepartitioning, and then a coding unit corresponding to a leaf node of abinary tree may be set as a root node for ternary tree partitioning. Inthis case, neither quad tree partitioning nor binary tree partitioningmay not be performed on the coding unit corresponding to a node of aternary tree.

A coding unit that cannot be partitioned by a quad tree partitionstructure, a binary tree partition structure, and/or a ternary treepartition structure becomes a basic unit for coding, prediction and/ortransformation. That is, the coding unit cannot be further partitionedfor prediction and/or transformation. Therefore, the partition structureinformation and the partition information used for partitioning a codingunit into prediction units and/or transformation units may not bepresent in a bitstream.

However, when the size of a coding unit (i.e., a basic unit forpartitioning) is larger than the size of a maximum transformation block,the coding unit may be recursively partitioned until the size of thecoding unit is reduced to be equal to or smaller than the size of themaximum transformation block. For example, when the size of a codingunit is 64×64 and when the size of a maximum transformation block is32×32, the coding unit may be partitioned into four 32×32 blocks fortransformation. For example, when the size of a coding unit is 32×64 andthe size of a maximum transformation block is 32×32, the coding unit maybe partitioned into two 32×32 blocks for the transformation. In thiscase, the partitioning of the coding unit for transformation is notsignaled separately, and may be determined through comparison betweenthe horizontal or vertical size of the coding unit and the horizontal orvertical size of the maximum transformation block. For example, when thehorizontal size (width) of the coding unit is larger than the horizontalsize (width) of the maximum transformation block, the coding unit may bevertically bisected. For example, when the vertical size (height) of thecoding unit is larger than the vertical size (height) of the maximumtransformation block, the coding unit may be horizontally bisected.

Information of the maximum and/or minimum size of the coding unit andinformation of the maximum and/or minimum size of the transformationblock may be signaled or determined at an upper level of the codingunit. The upper level may be, for example, a sequence level, a picturelevel, a slice level, or the like. For example, the minimum size of thecoding unit may be determined to be 4×4. For example, the maximum sizeof the transformation block may be determined to be 64×64. For example,the minimum size of the transformation block may be determined to be4×4.

Information of the minimum size (quad tree minimum size) of a codingunit corresponding to a leaf node of a quad tree and/or information ofthe maximum depth (the maximum tree depth of a multi-type tree) from aroot node to a leaf node of the multi-type tree may be signaled ordetermined at an upper level of the coding unit. For example, the upperlevel may be a sequence level, a picture level, a slice level, or thelike. Information of the minimum size of a quad tree and/or informationof the maximum depth of a multi-type tree may be signaled or determinedfor each of an intra slice and an inter slice.

Difference information between the size of a CTU and the maximum size ofa transformation block may be signaled or determined at an upper levelof the coding unit. For example, the upper level may be a sequencelevel, a picture level, a slice level, or the like. Information of themaximum size of the coding units corresponding to the respective nodesof a binary tree (hereinafter, referred to as a maximum size of a binarytree) may be determined based on the size of the coding tree unit andthe difference information. The maximum size of the coding unitscorresponding to the respective nodes of a ternary tree (hereinafter,referred to as a maximum size of a ternary tree) may vary depending onthe type of slice. For example, for an intra slice, the maximum size ofa ternary tree may be 32×32. For example, for an inter slice, themaximum size of a ternary tree may be 128×128. For example, the minimumsize of the coding units corresponding to the respective nodes of abinary tree (hereinafter, referred to as a minimum size of a binarytree) and/or the minimum size of the coding units corresponding to therespective nodes of a ternary tree (hereinafter, referred to as aminimum size of a ternary tree) may be set as the minimum size of acoding block.

As another example, the maximum size of a binary tree and/or the maximumsize of a ternary tree may be signaled or determined at the slice level.Alternatively, the minimum size of the binary tree and/or the minimumsize of the ternary tree may be signaled or determined at the slicelevel.

Depending on size and depth information of the above-described variousblocks, quad partition information, multi-type tree partition indicationinformation, partition tree information and/or partition directioninformation may be included or may not be included in a bit stream.

For example, when the size of the coding unit is not larger than theminimum size of a quad tree, the coding unit does not contain quadpartition information. Thus, the quad partition information may bededuced from a second value.

For example, when the sizes (horizontal and vertical sizes) of a codingunit corresponding to a node of a multi-type tree are larger than themaximum sizes (horizontal and vertical sizes) of a binary tree and/orthe maximum sizes (horizontal and vertical sizes) of a ternary tree, thecoding unit may not be binary-tree partitioned or ternary-treepartitioned. Accordingly, the multi-type tree partition indicationinformation may not be signaled but may be deduced from a second value.

Alternatively, when the sizes (horizontal and vertical sizes) of acoding unit corresponding to a node of a multi-type tree are the same asthe maximum sizes (horizontal and vertical sizes) of a binary treeand/or are two times as large as the maximum sizes (horizontal andvertical sizes) of a ternary tree, the coding unit may not be furtherbinary-tree partitioned or ternary-tree partitioned. Accordingly, themulti-type tree partition indication information may not be signaled butbe derived from a second value. This is because when a coding unit ispartitioned by a binary tree partition structure and/or a ternary treepartition structure, a coding unit smaller than the minimum size of abinary tree and/or the minimum size of a ternary tree is generated.

Alternatively, when the depth of a coding unit corresponding to a nodeof a multi-type tree is equal to the maximum depth of the multi-typetree, the coding unit may not be further binary-tree partitioned and/orternary-tree partitioned. Accordingly, the multi-type tree partitionindication information may not be signaled but may be deduced from asecond value.

Alternatively, only when at least one of vertical direction binary treepartitioning, horizontal direction binary tree partitioning, verticaldirection ternary tree partitioning, and horizontal direction ternarytree partitioning is possible for a coding unit corresponding to a nodeof a multi-type tree, the multi-type tree partition indicationinformation may be signaled. Otherwise, the coding unit may not bebinary-tree partitioned and/or ternary-tree partitioned. Accordingly,the multi-type tree partition indication information may not be signaledbut may be deduced from a second value.

Alternatively, only when both of the vertical direction binary treepartitioning and the horizontal direction binary tree partitioning orboth of the vertical direction ternary tree partitioning and thehorizontal direction ternary tree partitioning are possible for a codingunit corresponding to a node of a multi-type tree, the partitiondirection information may be signaled. Otherwise, the partitiondirection information may not be signaled but may be derived from avalue indicating possible partitioning directions.

Alternatively, only when both of the vertical direction binary treepartitioning and the vertical direction ternary tree partitioning orboth of the horizontal direction binary tree partitioning and thehorizontal direction ternary tree partitioning are possible for a codingtree corresponding to a node of a multi-type tree, the partition treeinformation may be signaled. Otherwise, the partition tree informationmay not be signaled but be deduced from a value indicating a possiblepartitioning tree structure.

FIG. 4 is a view showing an intra-prediction process.

Arrows from center to outside in FIG. 4 may represent predictiondirections of intra prediction modes.

Intra encoding and/or decoding may be performed by using a referencesample of a neighbor block of the current block. A neighbor block may bea reconstructed neighbor block. For example, intra encoding and/ordecoding may be performed by using an encoding parameter or a value of areference sample included in a reconstructed neighbor block.

A prediction block may mean a block generated by performing intraprediction. A prediction block may correspond to at least one among CU,PU and TU. A unit of a prediction block may have a size of one among CU,PU and TU. A prediction block may be a square block having a size of2×2, 4×4, 16×16, 32×32 or 64×64 etc. or may be a rectangular blockhaving a size of 2×8, 4×8, 2×16, 4×16 and 8×16 etc.

Intra prediction may be performed according to intra prediction mode forthe current block. The number of intra prediction modes which thecurrent block may have may be a fixed value and may be a valuedetermined differently according to an attribute of a prediction block.For example, an attribute of a prediction block may comprise a size of aprediction block and a shape of a prediction block, etc.

The number of intra-prediction modes may be fixed to N regardless of ablock size. Or, the number of intra prediction modes may be 3, 5, 9, 17,34, 35, 36, 65, or 67 etc. Alternatively, the number of intra-predictionmodes may vary according to a block size or a color component type orboth. For example, the number of intra prediction modes may varyaccording to whether the color component is a luma signal or a chromasignal. For example, as a block size becomes large, a number ofintra-prediction modes may increase. Alternatively, a number ofintra-prediction modes of a luma component block may be larger than anumber of intra-prediction modes of a chroma component block.

An intra-prediction mode may be a non-angular mode or an angular mode.The non-angular mode may be a DC mode or a planar mode, and the angularmode may be a prediction mode having a specific direction or angle. Theintra-prediction mode may be expressed by at least one of a mode number,a mode value, a mode numeral, a mode angle, and mode direction. A numberof intra-prediction modes may be M, which is equal to or larger than 1,including the non-angular and the angular mode.

In order to intra-predict a current block, a step of determining whetheror not samples included in a reconstructed neighbor block may be used asreference samples of the current block may be performed. When a samplethat is not usable as a reference sample of the current block ispresent, a value obtained by duplicating or performing interpolation onat least one sample value among samples included in the reconstructedneighbor block or both may be used to replace with a non-usable samplevalue of a sample, thus the replaced sample value is used as a referencesample of the current block.

When intra-predicting, a filter may be applied to at least one of areference sample and a prediction sample based on an intra-predictionmode and a current block size/shape.

In case of a planar mode, when generating a prediction block of acurrent block, according to a position of a prediction target samplewithin a prediction block, a sample value of the prediction targetsample may be generated by using a weighted sum of an upper and leftside reference sample of a current sample, and a right upper side andleft lower side reference sample of the current block. In addition, incase of a DC mode, when generating a prediction block of a currentblock, an average value of upper side and left side reference samples ofthe current block may be used. In addition, in case of an angular mode,a prediction block may be generated by using an upper side, a left side,a right upper side, and/or a left lower side reference sample of thecurrent block. In order to generate a prediction sample value,interpolation of a real number unit may be performed.

An intra-prediction mode of a current block may be entropyencoded/decoded by predicting an intra-prediction mode of a blockpresent adjacent to the current block. When intra-prediction modes ofthe current block and the neighbor block are identical, information thatthe intra-prediction modes of the current block and the neighbor blockare identical may be signaled by using predetermined flag information.In addition, indicator information of an intra-prediction mode that isidentical to the intra-prediction mode of the current block amongintra-prediction modes of a plurality of neighbor blocks may besignaled. When intra-prediction modes of the current block and theneighbor block are different, intra-prediction mode information of thecurrent block may be entropy encoded/decoded by performing entropyencoding/decoding based on the intra-prediction mode of the neighborblock.

FIG. 5 is a diagram illustrating an embodiment of an inter-pictureprediction process.

In FIG. 5, a rectangle may represent a picture. In FIG. 5, an arrowrepresents a prediction direction. Pictures may be categorized intointra pictures (I pictures), predictive pictures (P pictures), andBi-predictive pictures (B pictures) according to the encoding typethereof.

The I picture may be encoded through intra-prediction without requiringinter-picture prediction. The P picture may be encoded throughinter-picture prediction by using a reference picture that is present inone direction (i.e., forward direction or backward direction) withrespect to a current block. The B picture may be encoded throughinter-picture prediction by using reference pictures that are preset intwo directions (i.e., forward direction and backward direction) withrespect to a current block. When the inter-picture prediction is used,the encoder may perform inter-picture prediction or motion compensationand the decoder may perform the corresponding motion compensation.

Hereinbelow, an embodiment of the inter-picture prediction will bedescribed in detail.

The inter-picture prediction or motion compensation may be performedusing a reference picture and motion information.

Motion information of a current block may be derived duringinter-picture prediction by each of the encoding apparatus 100 and thedecoding apparatus 200. The motion information of the current block maybe derived by using motion information of a reconstructed neighboringblock, motion information of a collocated block (also referred to as acol block or a co-located block), and/or a block adjacent to theco-located block. The co-located block may mean a block that is locatedspatially at the same position as the current block, within a previouslyreconstructed collocated picture (also referred to as a col picture or aco-located picture). The co-located picture may be one picture among oneor more reference pictures included in a reference picture list.

A method of deriving the motion information of the current block mayvary depending on a prediction mode of the current block. For example,as prediction modes for inter-picture prediction, there may be an AMVPmode, a merge mode, a skip mode, a current picture reference mode, etc.The merge mode may be referred to as a motion merge mode.

For example, when the AMVP is used as the prediction mode, at least oneof motion vectors of the reconstructed neighboring blocks, motionvectors of the co-located blocks, motion vectors of blocks adjacent tothe co-located blocks, and a (0, 0) motion vector may be determined asmotion vector candidates for the current block, and a motion vectorcandidate list is generated by using the emotion vector candidates. Themotion vector candidate of the current block can be derived by using thegenerated motion vector candidate list. The motion information of thecurrent block may be determined based on the derived motion vectorcandidate. The motion vectors of the collocated blocks or the motionvectors of the blocks adjacent to the collocated blocks may be referredto as temporal motion vector candidates, and the motion vectors of thereconstructed neighboring blocks may be referred to as spatial motionvector candidates.

The encoding apparatus 100 may calculate a motion vector difference(MVD) between the motion vector of the current block and the motionvector candidate and may perform entropy encoding on the motion vectordifference (MVD). In addition, the encoding apparatus 100 may performentropy encoding on a motion vector candidate index and generate abitstream. The motion vector candidate index may indicate an optimummotion vector candidate among the motion vector candidates included inthe motion vector candidate list. The decoding apparatus may performentropy decoding on the motion vector candidate index included in thebitstream and may select a motion vector candidate of a decoding targetblock from among the motion vector candidates included in the motionvector candidate list by using the entropy-decoded motion vectorcandidate index. In addition, the decoding apparatus 200 may add theentropy-decoded MVD and the motion vector candidate extracted throughthe entropy decoding, thereby deriving the motion vector of the decodingtarget block.

The bitstream may include a reference picture index indicating areference picture. The reference picture index may be entropy-encoded bythe encoding apparatus 100 and then signaled as a bitstream to thedecoding apparatus 200. The decoding apparatus 200 may generate aprediction block of the decoding target block based on the derivedmotion vector and the reference picture index information.

Another example of the method of deriving the motion information of thecurrent may be the merge mode. The merge mode may mean a method ofmerging motion of a plurality of blocks. The merge mode may mean a modeof deriving the motion information of the current block from the motioninformation of the neighboring blocks. When the merge mode is applied,the merge candidate list may be generated using the motion informationof the reconstructed neighboring blocks and/or the motion information ofthe collocated blocks. The motion information may include at least oneof a motion vector, a reference picture index, and an inter-pictureprediction indicator. The prediction indicator may indicateone-direction prediction (L0 prediction or L1 prediction) ortwo-direction predictions (L0 prediction and L1 prediction).

The merge candidate list may be a list of motion information stored. Themotion information included in the merge candidate list may be at leasteither one of the zero merge candidate and new motion information thatis a combination of the motion information (spatial merge candidate) ofone neighboring block adjacent to the current block, the motioninformation (temporal merge candidate) of the collocated block of thecurrent block, which is included within the reference picture, and themotion information exiting in the merge candidate list.

The encoding apparatus 100 may generate a bitstream by performingentropy encoding on at least one of a merge flag and a merge index andmay signal the bitstream to the decoding apparatus 200. The merge flagmay be information indicating whether or not to perform the merge modefor each block, and the merge index may be information indicating thatwhich neighboring block, among the neighboring blocks of the currentblock, is a merge target block. For example, the neighboring blocks ofthe current block may include a left neighboring block on the left sideof the current block, an upper neighboring block disposed above thecurrent block, and a temporal neighboring block temporally adjacent tothe current block.

The skip mode may be a mode in which the motion information of theneighboring block is applied to the current block as it is. When theskip mode is applied, the encoding apparatus 100 may perform entropyencoding on information of the fact that the motion information of whichblock is to be used as the motion information of the current block togenerate a bit stream, and may signal the bitstream to the decodingapparatus 200. The encoding apparatus 100 may not signal a syntaxelement regarding at least any one of the motion vector differenceinformation, the encoding block flag, and the transform coefficientlevel to the decoding apparatus 200.

The current picture reference mode may mean a prediction mode in which apreviously reconstructed region within a current picture to which thecurrent block belongs is used for prediction. Here, a vector may be usedto specify the previously-reconstructed region. Information indicatingwhether the current block is to be encoded in the current picturereference mode may be encoded by using the reference picture index ofthe current block. The flag or index indicating whether or not thecurrent block is a block encoded in the current picture reference modemay be signaled, and may be deduced based on the reference picture indexof the current block. In the case where the current block is encoded inthe current picture reference mode, the current picture may be added tothe reference picture list for the current block so as to be located ata fixed position or a random position in the reference picture list. Thefixed position may be, for example, a position indicated by a referencepicture index of 0, or the last position in the list. When the currentpicture is added to the reference picture list so as to be located atthe random position, the reference picture index indicating the randomposition may be signaled.

FIG. 6 is a diagram illustrating a transform and quantization process.

As illustrated in FIG. 6, a transform and/or quantization process isperformed on a residual signal to generate a quantized level signal. Theresidual signal is a difference between an original block and aprediction block (i.e., an intra prediction block or an inter predictionblock). The prediction block is a block generated through intraprediction or inter prediction. The transform may be a primarytransform, a secondary transform, or both. The primary transform of theresidual signal results in transform coefficients, and the secondarytransform of the transform coefficients results in secondary transformcoefficients.

At least one scheme selected from among various transform schemes whichare preliminarily defined is used to perform the primary transform. Forexample, examples of the predefined transform schemes include discretecosine transform (DCT), discrete sine transform (DST), andKarhunen-Loève transform (KLT). The transform coefficients generatedthrough the primary transform may undergo the secondary transform. Thetransform schemes used for the primary transform and/or the secondarytransform may be determined according to coding parameters of thecurrent block and/or neighboring blocks of the current block.Alternatively, the transform scheme may be determined through signalingof transform information.

Since the residual signal is quantized through the primary transform andthe secondary transform, a quantized-level signal (quantizationcoefficients) is generated. The quantized level signal may be scannedaccording to at least one of a diagonal up-right scan, a vertical scan,and a horizontal scan, depending on an intra prediction mode of a blockor a block size/shape. For example, as the coefficients are scanned in adiagonal up-right scan, the coefficients in a block form change into aone-dimensional vector form. Aside from the diagonal up-right scan, thehorizontal scan of horizontally scanning a two-dimensional block form ofcoefficients or the vertical scan of vertically scanning atwo-dimensional block form of coefficients may be used depending on theintra prediction mode and/or the size of a transform block. The scannedquantized-level coefficients may be entropy-encoded to be inserted intoa bitstream.

A decoder entropy-decodes the bitstream to obtain the quantized-levelcoefficients. The quantized-level coefficients may be arranged in atwo-dimensional block form through inverse scanning. For the inversescanning, at least one of a diagonal up-right scan, a vertical scan, anda horizontal scan may be used.

The quantized-level coefficients may then be dequantized, then besecondary-inverse-transformed as necessary, and finally beprimary-inverse-transformed as necessary to generate a reconstructedresidual signal.

As described above, a video may be divided into a plurality of blockunits and then encoded/decoded. Units and blocks may be usedinterchangeably herein.

FIG. 7 is a diagram illustrating various embodiments for dividing oneblock (e.g., CTU, CTB, or CU) into a plurality of blocks (e.g., CU, PU,or TU). In FIG. 7, w represents a horizontal size of the block, and hrepresents a vertical size of the block.

For example, one CTU may be recursively divided into a plurality of CUsusing a quad tree structure. A prediction method (intra-prediction orinter-prediction) to be applied in units of one CU may be determined.

For example, one CU may be divided into M PUs. Also, for example, one CUmay be recursively divided into N TUs using a quad tree structure.Herein, M and N may be positive integers of 2 or more.

As an example of dividing a video into a plurality of blocks, it ispossible to perform division using a quad tree structure and thenperform division using a binary tree structure. In the following, thisdivision structure is defined as “binary-tree after quad-tree” division.

For example, in the example shown in FIG. 7, one CTU may be divided byperforming the binary-tree after quad tree division to be recursivelydivided into two or four CUs. In binary-tree after quad tree divisionstructure, the quad tree division may be performed earlier than thebinary tree division. Here, when one block is divided into two blocks,it may be considered that the block is divided using a binary tree (BT)structure. The size and/or form of the two blocks generated by thebinary tree division may be the same or different from each other. Whenone block is divided into four blocks, it may be considered that theblock is divided using a quad tree structure. The size and/or form ofsome or all of the four blocks generated by quad tree division may bethe same or different from each other. The CUs obtained by dividing theCTU using the binary-tree after quad tree division structure may have asquare or a non-square (rectangular) form.

At least one of the first flag and the first index may be signaled whenthe CU is divided using the binary-tree after quad tree divisionstructure.

When the first flag indicates a first value, it may indicate that thecorresponding CU is divided by performing the quad tree division. Whenthe first flag indicates a second value, it may indicate that thecorresponding CU is no longer divided.

When the first index indicates a first value, it may indicate that thecorresponding CU is no longer divided. When the first index indicates asecond value, it indicates that the corresponding CU is symmetricallydivided in the horizontal direction. When the first index indicates athird value, it indicates that the corresponding CU is symmetricallydivided in the vertical direction.

The first flag and the first index indicating whether the division isperformed or not and/or what is the division type for the correspondingCU may be signaled as separate syntax elements and signaled as onesyntax element. Alternatively, information indicating whether or not todivide the quad tree, information indicating whether or not to dividethe binary tree, and information indicating the binary tree divisiontype may be signaled separately, or may be signaled as a syntax elementin which some or all of them are integrated.

As in the example shown in FIG. 7, the binary tree symmetric divisionmay have two symmetric division (splitting) types, i.e., symmetricdivision in the horizontal direction or symmetric division in thevertical direction. In this case, a leaf node in the binary tree maymean a CU. In addition, blocks corresponding to two nodes obtained bythe binary tree symmetric division may have the same size.

As in the example shown in FIG. 7, the binary tree asymmetric divisionmay have two asymmetric division (splitting) types, i.e., asymmetricdivision in the horizontal direction or asymmetric division in thevertical direction. Likewise, a leaf node in the binary tree may mean aCU. In addition, blocks corresponding to two nodes obtained by thebinary tree asymmetric division may have different sizes from eachother. Unlike the case of binary tree symmetric division, in case of thebinary tree asymmetric division, information about division type and/ordivision ratio may be additionally signaled.

In the binary-tree after quad-tree division structure, a leaf node inthe quad tree may be further divided into a binary tree structure. Inthis case, the leaf node in the quad tree or the leaf node in the binarytree may mean a CU.

In the binary-tree after quad-tree division structure, the CUcorresponding to the final leaf node may be a unit of prediction andtransform without further division. That is, in the binary-tree afterquad-tree division structure, CU, PU and TU may all have the same size.Also, a prediction method (intra-prediction or inter-prediction) may bedetermined in units of CU. In the binary-tree after quad-tree divisionstructure, intra-prediction, inter-prediction, transform,inverse-transform, quantization, dequantization, entropyencoding/decoding, and in-loop filtering procedure may be performed inunits of a square or a non-square (rectangular) block.

A CU may include one luma (Y) component block and two chroma (Cb/Cr)component blocks. In addition, a CU may include only one luma componentblock or include only two chroma component blocks. In addition, a CU mayinclude only one luma component block, include only Cr chroma componentblock, or include only Cb chroma component block.

As another embodiment for dividing a video into a plurality of blocks, aquad-tree after binary-tree division structure may be used. “Quad-treeafter binary-tree division” means a division performing a division usinga binary tree structure and then performing a division using quad treestructure. “Quad-tree after binary-tree division” and “binary-tree afterquad-tree division” may differ only in the order of the tree structuresapplied to the division. Thus, the above description of “binary-treeafter quad-tree division” may be similarly applied to “quad-tree afterbinary-tree division” except for the order of the tree structures.

As another embodiment of dividing a video into a plurality of blocks, acombined quad-tree and binary-tree division structure may be used. Inthis case, one CTU may be recursively divided into two or four CUs usingthe combined quad-tree and binary-tree division structure. In thecombined quad-tree and binary-tree division structure, a quad-treedivision or a binary-tree division may be performed for one CU.

To a luma signal and a chroma signal within a video or one block (e.g.,a CTU), block division structures different from each other may beapplied. For example, a luma signal and a chroma signal within aspecific slice (I slice) or a block (e.g., a CTU) included in thecorresponding slice may be divided by using block division structuresdifferent from each other. A luma signal and a chroma signal withinother slice (e.g., P or B slice) or a block (e.g., a CTU) included inthe corresponding slice may be divided by using an identical blockdivision structure. Herein, when the chroma signal includes a Cb signaland a Cr signal, different intra-prediction modes may be used for the Cbsignal and the Cr signal, and intra-prediction modes of the Cb signaland the Cr signal may be entropy encoded/decoded, respectively. Anintra-prediction mode of a Cb signal may be entropy encoded/decoded byusing an intra-prediction mode of the Cr signal. Conversely, anintra-prediction mode of the Cr signal may be entropy encoded/decoded byusing an intra-prediction mode of the Cb signal.

FIG. 8 is a diagram illustrating an embodiment in which one block (forexample, a CTU or a CU) is divided by performing a binary-tree afterquad-tree division and information on whether or not division isperformed and/or a type of division is signaled.

Whether or not quad tree division is performed may be signaled by a QTsplit flag. Whether or not binary-tree division is performed may besignaled by a BT split flag. A type of binary-tree division may besignaled by a BT split type.

The current block (e.g., CU) has a square, triangular, or rectangularform and may correspond to a leaf node of a quad tree or a leaf node ofa binary tree. In addition, intra-prediction, inter-prediction,transform, inverse-transform, quantization, dequantization, entropyencoding/decoding, and in-loop filtering procedure may be performed inunits of a size, a form, and/or a depth of the current block.

The current block is divided into at least one symmetric and/orasymmetric sub-blocks, and intra-prediction and/or inter-predictioninformation different from each other may be derived for each sub-block.

FIG. 9 is a diagram illustrating various embodiments of dividing acurrent block into two sub-blocks.

In FIG. 9, two sub-blocks obtained by performing division are defined asa first sub-block and a second sub-block respectively, in which thefirst sub-block is referred to as a sub-block A, and the secondsub-block is referred to as a sub-block B.

When the current block is divided into at least one symmetric and/orasymmetric sub-block, the minimum size of the sub-block may be definedas M×N. In this case, M and N may be the same or different positiveintegers. For example, a 4×4 block may be defined as a minimum size of asub-block.

When the current block is divided into at least one symmetric and/orasymmetric sub-block, a flag indicating whether the sub-block is dividedor not in units of a block (for example, CU) and/or index information ona division type of the sub-block may be signaled and variably derived onthe basis of the encoding parameters of the current block.

When the current block is divided into at least one symmetric and/orasymmetric sub-block, no further block division may be performed forequal to or less than a specific block size or a specific block depth.The information on the specific block size or the specific block depthmay be entropy encoded/decoded in one or more units of a video parameterset VPS, a sequence parameter set SPS, a picture parameter set PPS, atile header, a slice header, CTU, and CU.

When the current block is divided into at least one asymmetricsub-blocks, the divided sub-blocks may have any other form than a squareand/or rectangular form.

For example, when the current block is divided into two sub-blocks, thecurrent block may be divided into two sub-blocks of a triangular formobtained by dividing it by a diagonal boundary from the upper leftcorner to the lower right corner of the current block or divided intotwo sub-blocks of a triangular form obtained by dividing it by adiagonal boundary from the upper right corner to the lower left cornerof the current block. Alternatively, the current block may be dividedinto four sub-blocks of a triangular form by dividing it by a diagonalboundary from the upper left corner to the lower right corner anddividing it by a diagonal boundary from the upper right corner to thelower left corner. The two sub-blocks of a triangular form may bereferred to as asymmetric sub-blocks divided in an asymmetric divisiontype.

FIG. 9(a) shows a current block (CU) in which no division is performed.

For example, when the current block is divided into two sub-blocks asshown in FIG. 9(b), the remaining area excluding the lower right area(the second sub-block (sub-block B)) of the current block is defined asa first sub-block (sub-block A).

The encoder/decoder may store a table or list including a plurality ofasymmetric division types. When an asymmetric division type of thecurrent block is determined in the encoder, an index and a flag aredetermined by referring to the table or list, and the index or the flagmay be transmitted to the decoder. Alternatively, the encoder/decodermay determine an asymmetric division type of the current block on thebasis of encoding parameters of the current block. In addition, theencoder/decoder may determine an asymmetric division type of the currentblock from a block neighboring to the current block. In this case, it ispossible to determine the asymmetric division type of the current blockon the basis of the encoding parameters such as a division type of theneighboring block.

When the current block is divided into at least one asymmetricsub-block, each sub-block may have a horizontal and/or vertical sizethat is equal to or less than the width w and/or the height h of thecurrent block.

For example, when the current block is divided into two sub-blocks asshown in FIGS. 9(b) to (e), the second sub-block may have a size of3w/4×3h/4.

Meanwhile, the ratio of the horizontal and/or vertical length of thesecond sub-block to the current block may be set at a predeterminedratio in the encoder and the decoder or may be set on the basis ofinformation signaled frin the encode to the decoder.

The current block (e.g., CU) may mean a leaf node of a quad tree or aleaf node of a binary tree. At least one of encoding/decoding processessuch as intra-prediction, inter-prediction, primary/secondary transform,inverse-transform, quantization, dequantization, entropyencoding/decoding, in-loop filtering, and the like that are performedfor encoding/decoding the current block may be performed in units of asize, a form, and/or a depth of a sub-block.

When the current block is divided into at least one or more symmetricand/or asymmetric sub-blocks, the prediction information of the currentblock may be derived by using at least one method of derivinginter-picture prediction information different between sub-blocks,deriving intra-prediction information different between sub-blocks, andderiving combined intra-prediction/inter-prediction information betweensub-blocks.

When the current block is divided into at least one symmetric and/orasymmetric sub-block, the flag for indicating whether or not thesub-block is divided in units of a block (for example, CU) and/or indexinformation for a division type of the sub-block may be signaled througha bitstream and variably derived on the basis of the encoding parameterof the current block. In this case, it is possible to define thedivision type of the sub-block by using at least one type of asymmetricsub-block division types in FIG. 9(b) to (j) and then performencoding/decoding. For example, when four types of FIG. 9(b) to (e) areused, a flag indicating whether or not sub-block-based encoding anddecoding is performed and a sub-block division index may be signaledthrough a bitstream or be variably derived on the basis of the encodingparameters of the current block. Herein, when explicitly transmittingthe index information, at least one of the following entropyencoding/decoding methods may be used, and encoding/decoding may befinally performed by using CABAC(ae(v)) after performing binarization.

Truncated rice binarization method

K-th order exp_golomb binarization method

Restricted K-th order exp_golomb binarization method

Fixed-length binarization method

Unary binarization method

Truncated unary binarization method

Whether the current block is divided into at least one symmetric and/orasymmetric sub-blocks may be determined on the basis of at least one ofa slice type, a picture type, and a tile group type of the currentblock. Here, the slice type may mean at least one of an I slice, a Pslice, and a B slice. In addition, the picture type may mean at leastone of an I picture, a P picture, and a B picture. Also, the tile groupmay mean a picture division type including at least one tile, and thetile group may mean at least one of an I tile group, a P tile group, anda B tile group. Also, the slice may be used as the same meaning as apicture and a tile group.

In addition, whether or not the current block is divided into at leastone symmetric and/or asymmetric sub-blocks may be determined on thebasis of the size of the current block. For example, when the currentblock has a horizontal size of w and a vertical size of h, it may bedetermined whether or not to be divided into symmetric and/or asymmetricsub-blocks by comparing values of w*h or w+h with a value for aparticular size.

In addition, whether or not the current block is divided into at leastone symmetric and/or asymmetric sub-blocks may be determined accordingto an encoding mode of the current block. For example, when the currentblock is a skip mode or a merge mode, the current block may be dividedinto one or more symmetric and/or asymmetric sub-blocks.

When the current block is divided into at least one symmetric and/orasymmetric sub-block, the motion vector value between each sub-block, amotion vector difference value, a reference picture, a reference picturelist, a prediction list utilization flag value, a weighted value usedfor generating the final prediction block by adding the sub-blocks maybe different from each other.

FIG. 10 is a view showing intra-prediction according to the presentinvention.

Intra-prediction of a current block may include: step S1010 of derivingan intra-prediction mode, step S1020 of configuring a reference sample,and/or step S1030 of performing intra-prediction.

In step S1010, an intra-prediction mode of a current block may bederived. The intra-prediction mode of the current block may be derivedby using a method of using an intra-prediction mode of a neighbor block,a method of entropy encoding/decoding an intra-prediction mode of acurrent block from a bitstream, a method of using a coding parameter ofa neighbor block or a method of using intra prediction mode of a colorcomponent. According to the method of using the intra-prediction mode ofthe neighbor block, the intra-prediction mode of the current block maybe derived by using at least one intra-prediction mode derived by usingan intra-prediction mode of a neighbor block, a combination of at leastone intra-prediction mode of a neighbor block, and at least one MPM.

In step S1020, a reference sample may be configured by performing atleast one of reference sample selecting, reference sample padding andreference sample filtering.

In step S1030, intra-prediction may be performed by performing at leastone of non-angular prediction, angular prediction, positionalinformation based prediction, inter color component prediction, andtemplate matching-based intra-prediction. In step S1030, filtering on aprediction sample may be additionally performed.

In order to derive the intra-prediction mode of the current block, atleast one reconstructed neighbor block may be used. A position of thereconstructed neighbor block may be a fixed position that is predefined,or may be a position derived by encoding/decoding. Hereinafter,encoding/decoding may mean entropy encoding and decoding. For example,when a coordinate of a left upper corner side sample of a current blockhaving a W×H size is (0, 0), a neighbor block may be at least one ofblocks adjacent to coordinate of (−1, H−1), (W−1, −1), (W, −1), (−1, H),and (−1, −1), and neighbor blocks of the above blocks. Here, W and H mayrepresent length or the number of samples of width (W) and height (H) ofthe current block.

An intra-prediction mode of a neighbor block which is not available maybe replaced with a predetermined intra-prediction mode. Thepredetermined intra-prediction mode may be, for example, a DC mode, aplanar mode, a vertical mode, a horizontal mode, and/or a diagonal mode.For example, when a neighbor block is positioned outside of a boundaryof at least one predetermined unit of a picture, a slice, a tile, and acoding tree unit, the neighbor block is inter-predicted, or when theneighbor block is encoded in a PCM mode, the corresponding block may bedetermined as non-available. Alternatively, when the neighbor block isunavailable, the intra prediction mode of the corresponding block is notreplaced and not used.

The intra-prediction mode of the current block may be derived as astatistical value of an intra-prediction mode of a predeterminedpositional neighbor block or an intra-prediction mode of at least twoneighbor blocks. In the present description, the statistical value maymean at least one of an average value, a maximum value, a minimum value,a mode, a median value, a weighted average value, and an interpolationvalue.

Alternatively, the intra-prediction mode of the current block may bederived based on a size of neighbor blocks. For example, anintra-prediction mode of a neighbor block having relatively large sizemay be derived as the intra-prediction mode of the current block.Alternatively, a statistical value may be calculated by assigning alarge weight on an intra-prediction mode of a block having relativelylarge size. Alternatively, a mode to which a relatively large weight isassigned may be pre-defined or signaled. For example, a relatively largeweight may be assigned to at least one among a vertical directionalmode, a horizontal directional mode, a diagonal directional mode andnon-directional mode. The same weight may be assigned to the abovemodes.

Alternatively, whether or not the intra-prediction mode of the neighborblock is angular mode may be considered. For example, when theintra-prediction mode of the neighbor block is a non-angular mode, thenon-angular mode may be derived as the intra-prediction mode of thecurrent block. Alternatively, an intra-prediction mode of other neighborblock, except for the non-angular mode, may be derived as theintra-prediction mode of the current block.

In order to derive the intra-prediction mode of the current block, it ispossible to construct one or more most probable mode (MPM) lists. TheMPM list includes one or more MPM candidate modes, and the MPM candidatemode may include an intra-prediction mode of at least one spatialneighboring block in which encoding/decoding is completed and/or a givenintra-prediction mode.

FIG. 11 is a diagram illustrating spatial neighboring blocks of acurrent block used when configuring an MPM list.

For example, assuming that the number of intra-prediction modesconfiguring the MPM list is six, as shown in FIG. 11, from at least oneof the spatial neighboring blocks of the current block, the candidatemodes to be included in the MPM list may be sequentially derived up to kat maximum (k is a positive integer of 6 or less). In the followingdescription, for example, k is 5.

The order of deriving the MPM candidate mode from the neighboring blocksmay be arbitrarily set by the encoder/decoder. For example, the MPMcandidate modes may be derived in the order of a left block L, a topblock A, a lower left block BL, an upper right block AR, and an upperleft block AL. Further, the MPM candidate modes may be derived in theorder of the left block L and the top block A. A Planar mode and/or a DCmode, which is a non-directional mode, may be regarded as anintra-prediction mode having a high probability of occurrence.Therefore, when the Planar mode and/or the DC mode are not included inthe five intra-prediction modes derived from the spatial neighboringblocks, the Planar mode and/or DC mode may be included in the MPM listas the MPM candidate mode. That is, the Planar mode and/or DC modes mayalways be included in the MPM candidate list.

Herein, the order in which the Planar mode and/or the DC mode arelocated in the MPM list may be arbitrarily set in the encoder/decoder.For example, the MPM list may be configured in the order of the leftblock L, the top block A, the Planar, the DC, the lower left block BL,the upper right block AR, and the upper left block AL. In addition, theMPM list may be configured in the order of the left block L, the topblock A, the Planar, and the DC.

The redundancy check may be performed to determine whether theintra-prediction modes in the configured MPM list are prediction modesdifferent from each other. When the number of intra-prediction modesincluded in the MPM list after the redundancy check is smaller than themaximum number (for example, six) of intra-prediction modes that the MPMlist may include, an intra-prediction mode in which a predeterminedoffset is added and/or subtracted to/from the intra-prediction modehaving directionality among intra-prediction modes included in the MPMlist may be additionally included in the MPM list. Herein, the offsetvalue is not limited to one but may be an integer of two or more.

When the MPM list is not filled through the above process, for example,when the number of the MPM candidate modes is less than six, the MPMlist is filled in the order of a vertical mode, a horizontal mode, and adiagonal mode, so that the MPM list may be configured with up to sixintra-prediction modes at maximum different from each other. The orderin which the default modes (vertical mode, horizontal mode, and diagonalmode) are filled is not limited to the above example and may be anysequence previously defined in the encoder/decoder. When the number ofintra-prediction modes is 67 at maximum, mode 0 indicates a Planar mode,mode 1 indicates a DC mode, and modes 2 through 66 may indicatedirectional modes. In addition, the vertical mode may be mode 50, thehorizontal mode may be mode 18, and the diagonal mode may be mode 2,mode 34, and/or mode 66.

For example, the candidate modes included in the MPM list configured asdescribed above may be rearranged according to a predeterminedcriterion.

FIG. 12 is a view illustrating an embodiment for rearranging candidatemodes in the MPM list.

A prediction block is generated for each candidate mode included in theMPM list, and a sum of absolute differences (SAD) is obtained in aboundary region between the generated prediction block and a neighboringreference sample of the current block. Thereafter, the MPM list may bereconfigured by rearranging the MPM candidate modes in the order(increasing order) from the intra-prediction mode having smaller SAD tothe intra-prediction mode having higher SAD.

Alternatively, the SAD may be calculated for each of the plurality ofMPM candidate modes, and then the MPM list may be configured withcandidate modes of the allowed maximum number of MPM candidate modes.Herein, the MPM list may be configured with candidate modes in order ofincreasing SAD.

When configuring the MPM list, one MPM list may be configured for thecurrent block of a predetermined size. When the current block of thepredetermined size is divided into a plurality of sub-blocks, theconfigured MPM list may be used for each sub-block. In this case, thesize of the current block and the sub-block may be, for example, M×N, inwhich M and N may be a predetermined integer, respectively. For example,the current block and/or the sub-block may have at least one of CTU, CU,signaling unit (SU), QTMax, QTMin, BTMax, BTMin, 4×4, 8×8, 16×16, 32×32,64×64, 128×128, 256×256, 4×8, 8×16, 16×8, 32×64, 32×8, 4×32, and thelike. In this case, QTMax and QTMin may indicate the maximum size andthe minimum size of a block that may be divided into a quad tree,respectively. In addition, BTMax and BTMin may indicate the maximum sizeand the minimum size of a block that may be divided into a binary tree,respectively. Hereinafter, the size of the sub-block may mean asub-block division structure.

The intra-prediction mode of the current block may be encoded/decodedusing an MPM flag and/or an MPM index (mpm_idx). The MPM flag mayindicate whether or not the same candidate mode as the intra-predictionmode of the current block is included in the MPM list. The MPM index mayindicate the same candidate as the intra-prediction mode of the currentblock among the candidate modes included in the MPM list.

For example, when the MPM flag is 1, the intra-prediction mode of thecurrent block (for example, the luminance component) may be derived byusing at least one of the MPM index mpm_idx and the intra-predictionmode of neighboring units to the encoded/decoded current block. Forexample, when the MPM flag is 1, the MPM list may be configuredaccording to the above-described method, and then the intra-predictionmode indicated by the MPM index may be derived as the intra-predictionmode of the current block.

When the configured MPM list is rearranged according to a predeterminedcriterion, the MPM index is not transmitted, and the candidate mode atany position in the MPM list may be derived as the intra-prediction modeof the current block. The predetermined criterion may be, for example,the Boundary SAD described above. Any position in the MPM list may be,for example, the first (index 0) position of the MPM list.

For example, when the MPM flag is 0, a secondary MPM list (second MPMlist) including one or more candidate modes may be configured. Inaddition, a secondary MPM flag (2nd MPM flag) indicating whether theintra-prediction mode of the current block is the same as the candidatemode included in the secondary MPM list may be encoded/decoded.

When the secondary MPM flag is 1, the secondary MPM index (2nd_mpm_idx)may be additionally encoded/decoded. In this case, the intra-predictionmode of the current block (e.g., luma component) may be derived using atleast one of the secondary MPM index and the intra-prediction mode ofthe encoded/decoded adjacent units.

The candidate mode included in the secondary MPM list may be determinedon the basis of the intra-prediction mode of the neighboring blocks ofthe current block. For example, the intra-prediction mode of the leftblock or the top block of the current block may be used. Alternatively,when the sub-blocks adjacent to the top of the current block have one ormore intra-prediction modes different from each other, the correspondingintra-prediction modes may be included in the secondary MPM list.Similarly, when the sub-blocks adjacent to the left of the current blockhave one or more intra-prediction modes different from each other, theintra-prediction modes may be included in the secondary MPM list.Alternatively, it is possible to configure the secondary MPM list byusing the intra-prediction modes of blocks in which theencoding/decoding is completed earlier than the current block asintra-predicted blocks in the current slice.

When both the MPM flag and the secondary MPM flag are 0, theintra-prediction mode of the current block (for example, luma component)may be encoded/decoded using the luminance component residualintra-prediction mode index (rem_intra_luma_pred_mode).

Also, the intra-prediction mode of chroma component may be derived usingat least one of a chroma component residual intra-prediction mode index(intra_chroma_pred_mode) and/or an intra-prediction mode of thecorresponding luma block. A method of deriving the intra-prediction modeof the chroma component on the basis of an intra-prediction mode of theluma block will be described later.

Hereinafter, other embodiment will be described in which encodedinformation around the current block is used to configure one or morecandidate modes included in the MPM list (and/or the secondary MPMlist).

For example, for each of all the intra-prediction modes, a predictionsample of the current block may be generated. When a prediction block isgenerated, as described with reference to FIG. 12, a boundary SAD may becalculated between the neighboring reference sample of the current blockand the generated prediction sample. Thereafter, the modes are arrangedin order of increasing SAD, and the MPM list (and/or the secondary MPMlist) may include the candidate modes from the intra-prediction havingsmaller SAD up to the maximum number of candidate modes that the MPMlist (and/or secondary MPM list) may include.

In the embodiment shown in FIG. 12, when 8×8 current blocks areintra-predicted, a prediction block may be generated for each of all theintra-prediction modes allowed in the encoder/decoder. A boundary SADmay be calculated between boundary regions (dotted line region) locatedat the left column, the upper left sample, and/or the top row andsurrounding reference sample (gray region) located in the upper row ofeach generated prediction block. The intra-prediction modes may bearranged in order of increasing SAD. The intra-prediction modes may beincluded in the MPM list (and/or the secondary MPM list) as a candidatemode according to the arranged order.

When one reference sample line or more are used, calculation of theboundary SAD may be performed for each of the reference sample lines.Alternatively, when calculating the boundary SAD, one or more columnsmay be considered for the left column of the prediction block of thecurrent block, and similarly one or more rows may be considered for thetop row of the prediction block of the current block.

As other embodiment, after searching other area in the current slice inwhich encoding/decoding is completed, for a block most similar to thecurrent block, it is possible to apply the above method (a method usingBoundary SAD). In this case, after applying the above method orgenerating the block most similar to the current block and a predictionblock according to the intra-prediction mode in the corresponding block,an intra-prediction mode in which the difference value between the twoblocks is at minimum is obtained and then included in the MPM list(and/or the secondary MPM list).

Information indicating that the MPM list (and/or the second MPM list)has been configured by using at least one of the above methods may beencoded/decoded or implicitly derived by the decoder. Whenencoding/decoding the information indicating that the MPM list (and/orthe 2nd MPM list) has been configured, at least one of the followingentropy encoding/decoding methods may be used, and encoding/decoding maybe finally performed by using CABAC(ae(v)) after performingbinarization.

Truncated rice binarization method

K-th order exp_golomb binarization method

Restricted K-th order exp_golomb binarization method

Fixed-length binarization method

Unary binarization method

Truncated unary binarization method

According to a further embodiment of the present invention relating to amethod of deriving an intra prediction mode, an intra prediction mode ofa current block may be derived by using an intra prediction mode of adifferent color component. For example, when the current block is achroma block, an intra prediction mode of a luma block corresponding tothe chroma block can be used to derive an intra prediction mode of thechroma block. As the luma block corresponding to the chroma block, theremay be one or more luma blocks. The corresponding luma block may bedetermined depending on at least any one of a position of the lumablock, a position of the chroma block, an upper-left sample position ofthe luma block, an upper-left sample position of the chroma block, thesize of the luma block, the size, the shape, and the encoding parameterof the chroma block. Alternatively, the corresponding luma block may bedetermined depending on at least any one of the size, the shape, and theencoding parameter of a luma block.

The luma block corresponding to the chroma block may be composed of aplurality of partitions. All or part of the plurality of partitions mayhave different intra prediction modes thereof. An intra prediction modeof the chroma block may be derived on the basis of all or part of theplurality of partitions included in the corresponding luma block. Inthis case, some partitions may be selectively used, in which the usedpartitions are selected based on the comparison of the block size, theshape, the depth information, etc. of the chroma block with those of theluma block (all or part of the plurality of partitions). A partition ata position in the luma block corresponding to a predetermined positionin the chroma block may be selectively used. The predetermined positionmay refer to a corner sample (e.g., upper left sample) position in thechroma block or a center sample position in the chroma block. The centersample position may be determined based on an upper-left position of aluma/chroma block, half horizontal size of a luma/chroma block, halfvertical size a luma/chroma block. For example, position of x-axisdirection of the center sample may be determined by adding halfhorizontal size of a luma/chroma block to an upper-left position of theluma/chroma block in horizontal direction. Also, position of y-axisdirection of the center sample may be determined by adding half verticalsize of a luma/chroma block to an upper-left position of the luma/chromablock in vertical direction. Here, position of a luma blockcorresponding to a center sample position of the chroma block may mean acenter sample position of the luma block.

The method of deriving an intra prediction mode of one color componentblock using an intra prediction mode of a different color componentblock (i.e. inter color component intra prediction mode) according tothe present invention is not limited to the example in which an intraprediction mode of a luma block corresponding to a chroma block is used.For example, an intra prediction mode of a chroma block may be derivedby using or sharing at least any one of an MPM index mpm_idx and an MPMlist of a luma block corresponding to the chroma block.

FIG. 13 is an exemplary diagram illustrating the relationship between aluma block and a chroma block.

In the example illustrated in FIG. 13, a sample ratio of colorcomponents is 4:2:0, and at least one of luma blocks A, B, C, and Dcorresponds to one chroma block.

With reference to FIG. 13, an intra prediction mode of one chroma blockmay be derived by using an intra prediction mode of the luma block Acorresponding to a sample at an upper left position (0,0) in the chromablock, an intra prediction mode of the luma block D corresponding to asample at a center position (nS/2, nS/2) in the chroma block, or anintra prediction mode of the luma block B corresponding to a sample atanother center position ((nS/2)−1, (nS/2)−1) in the chroma block. Thepredetermined position in the chroma block is not limited to (0, 0),((nS/2)−1, (nS/2)−1) and (nS/2, nS/2). For example, The predeterminedposition may be an upper right position, a lower left position, and/or alower right position. A center position of the chroma block may be (W/2,H/2) where W is block width and H is block height. Also, a centerposition of the chroma block may be ((W/2)−1, (H/2)−1).

The predetermined position may be selected on the basis of the shape ofthe chroma block. For example, with the chroma block having a squareshape, the predetermined position may be a center sample position. Withthe chroma block having an oblong shape, the predetermined position maybe an upper left sample position. Alternatively, the predeterminedposition may be a position of an upper left sample in the chroma blockhaving a square shape or a position of a center sample in the chromablock having an oblong shape.

According to a further embodiment, an intra prediction mode of a chromablock may be derived by using statistic figures of one or more intraprediction modes of a luma block having an equal size to the chromablock.

In the example illustrated in FIG. 13, a mode corresponding to theaverage of the intra prediction modes of the luma blocks A and D or amode corresponding to the average of the intra prediction modes of theluma blocks A, B, C, and D having an equal size to the chroma block isderived as the intra prediction mode of the chroma block.

When there are multiple intra prediction modes of available luma blocks,all or part of them may be selected. The selection is performed based onthe predetermined position in the chroma block or based on the size(s),the shape(s), and/or the depth(s) of the chroma block, the luma block,or both. The intra prediction mode of the chroma block can be derived byusing the selected intra prediction mode of the luma block.

For example, the size of the luma block A corresponding to the upperleft sample position (0,0) in the chroma block and the size of theluminance bock D corresponding to the center sample position (nS/2,nS/2) in the chroma block are compared, and the intra prediction mode ofthe luma block D having a larger size may be used to derive the intraprediction mode of the chroma block.

Alternatively, when the size of a luma block corresponding to apredetermined position in a chroma block is equal to or larger than thesize of the chroma block, an intra prediction mode of the chroma blockis derived by using the intra prediction module of the luma block.

Alternatively, when the size of a chroma block is within a predeterminedrange, an intra prediction mode of the chroma block is derived by usingan intra prediction mode of a luma block corresponding to the upper leftsample position (0, 0) in the chroma block.

Alternatively, when the size of a chroma block is within a predeterminedrange, the size of a luma block corresponding to a predeterminedposition (0, 0) of the chroma block and the size of a luma blockdisposed at another predetermined position (nS/2, nS/2) of the chromablock are compared, and an intra prediction mode of the chroma block isderived by using the intra prediction mode of the luma block having alarger size.

The predetermined range may be derived from at least any one piece ofinformation among information signaled through a bitstream, informationof the size (and/or depth) of a block (a chroma block, a luma block, orboth), and information predefined in an encoder/decoder.

Alternatively, when a chroma block has an oblong shape, an intraprediction mode of the chroma block may be derived by using an intraprediction mode of a luma block corresponding to a center sampleposition (nS/2, nS/2) or an intra prediction mode of a luma blockcorresponding to another center sample position ((nS/2)−1, (nS/2)−1) inthe chroma block.

Among the plurality of partitions of the luma block, a partition havingthe same shape as the chroma block may be used. For example, when thechroma block has a square shape or a non-square shape, a partitionhaving a square shape or a non-square shape, selected among theplurality of partitions of the luma block, may be used.

In the example described with reference to FIG. 13, the method ofderiving an intra prediction mode of a chroma block using an intraprediction mode of a luma block also applies to a case in which an intraprediction mode of a luma block is used as an intra prediction mode of achroma block as it is. The method of deriving an intra prediction modeof a chroma block is not limited to the method of using an intraprediction mode of the corresponding luma block. For example, an intraprediction mode of a chroma block can be derived from information,including an MPM list and an MPM index mpm_idx, which is used to derivean intra prediction mode of a luma block.

Alternatively, the MPM list of the chroma block can be constructed usingthe intra prediction mode of the luma block corresponding to the sampleof the predetermined position in the chroma block. In this case, thempm-idx information of the chroma block may be encoded and signaled. TheMPM list of the chroma block may be constructed in a similar way to theconstruction of the MPM list of the luma block. MPM candidates of thechroma block may include intra prediction modes of neighbor chromablocks and/or intra prediction modes of luma blocks corresponding to thechroma block.

When an MPM flag is 0, a second MPM list including at least oneintra-prediction mode may be configured, and the intra-prediction modeof the current block may be derived by using a second MPM index(2nd_mpm_idx). Herein, a second indicator (for example, a second MPMflag) indicating whether or not the intra-prediction mode of the currentblock is included in the second MPM list may be encoded/decoded. Similarto a first MPM list, the second MPM list may be configured by usingintra-prediction modes of the neighbor block. Herein, theintra-prediction mode included in the first MPM list may not be includedin the second MPM list. A number of MPM lists is not limited to 1 or 2,N MPM lists may be used.

When the intra-prediction mode of the current block is not included inone of a plurality of MPM lists, a luma component intra-prediction modeof the current block may be encoded/decoded. In addition, a chromacomponent intra-prediction mode may be derived and encoded/decoded basedon an associated luma component intra-prediction mode.

When the current block is partitioned into a plurality of sub-blocks, inorder to derive an intra-prediction mode of each sub-block, at least oneof the described methods may be applied.

A size or form or both of a sub-block may be a predetermined size orblock or both (for example, 4×4), or may be determined according to asize or form or both of the current block. Alternatively, the size ofthe sub-block may be determined based on whether or not a neighbor blockof the current block is partitioned, or may be determined based on anintra-prediction mode of a neighbor block of the current block. Forexample, the current block may be partitioned based on a boundary atwhich an intra-prediction mode of a neighbor block is different.Alternatively, the current block may be partitioned based on whether theneighbor block is an intra coding block or an inter coding block.

An indicator (for example, NDIP_flag) representing that theintra-prediction mode of the current block is derived by using theintra-prediction mode of the neighbor block may be encoded/decoded. Theindicator may be encoded/decoded by at least one unit of the currentblock and the sub-block. Herein, when a size of the current block or thesub-block corresponds to a predetermined size or a predetermined sizerange, the indicator may be encoded/decoded.

Determining whether or not the size of the current block corresponds toa predetermined size may be performed based on a horizontal or verticallength of the current block. For example, when the horizontal orvertical length is a length capable of being partitioned, it isdetermined that the size of the current block corresponds to apredetermined size.

Intra-prediction information may be signaled through at least one of avideo parameter set (VPS), a sequence parameter set (SPS), a pictureparameter set (PPS), an adaptation parameter set (APS), a slice header,and a tile header. In a predetermined block size or less, at least onepiece of intra-prediction information may not be signaled. Herein,intra-prediction information of a previously encoded/decoded block (forexample, higher block) may be used.

A reference sample for intra-prediction may be configured based on thederived intra-prediction mode. In the description hereinafter, a currentblock may mean a prediction block or a sub-block having a size/formsmaller than a size/form of the prediction block. The reference samplemay be configured by using at least one sample reconstructed adjacent toa current block or by using a combination of samples. In addition,filtering may be applied to the configured reference sample.

A number or position or both of reconstructed sample lines used forconfiguring the reference sample may vary according to a position of acurrent block within a coding tree block. Each reconstructed sample on aplurality of reconstructed sample lines may be used as a referencesample at it is. Alternatively, a predetermined filter may be applied tothe reconstructed sample, and a reference sample may be generated byusing the filtered reconstructed sample. Reconstructed samples to whicha filter is applied may be included in the same reconstructed sampleline or in different reconstructed sample lines.

An indicator indicating whether multiple reference sample lines areutilized for prediction may be signaled. For example, an indicator suchas mrl_enabled_flag may be included in at least one of an SPS, a PPS,and a slice header so as to be signaled. The flag may be an indicatorindicating whether a single reference sample line is used or multiplereference sample lines are used.

When the indicator indicates that multiple reference sample lines areused, reference sample line indexes are also signaled. For example,mrl_index is signaled. Therefore, it is possible to determine whichreference sample lines are used.

When the indicator mrl_index has a value of 0, a first reference sampleline which is closest to the current block is utilized. On the otherhand, when the indicator mrl_index has a value of 1, a second referencesample line which is second closest to the current block is utilized.When the indicator mrl_index has a value of 2, a third closest referencesample line which is third closest to the current block is used. Thefirst to fourth reference sample lines respectively correspond toreconstructed sample lines 1 to 4 illustrated in FIG. 14, respectively.

The indicator mrl_index is signaled depending on at least one of theintra prediction mode, the MPM information, the size (with and height)of the current block, the presence or absence of an upper boundary of aCTU, and the color component. When the indicator mrl_index is notsignaled, the first reference sample line adjacent to the current blockis used.

For example, when the intra prediction mode is a predetermined mode, theindicator mrl_index may be signaled. The intra prediction mode may bethe intra prediction mode of the current block or at least one of theintra prediction modes of the respective neighboring blocks. Thepredetermined mode is at least one of non-directional prediction mode,directional prediction mode, vertical or horizontal mode, even-numberedmode, and odd-numbered mode. For example, when the intra prediction modeof a neighboring block adjacent to the left boundary or the upperboundary of the current block is one of directional modes, the indicatormrl_index may be signaled. Alternatively, when the intra prediction modeof the neighboring block is one of even-numbered modes or one ofodd-numbered modes, the indicator mrl_index may be signaled.

For example, the indicator mrl_index may be signaled on the basis of theMPM information of the current block. The MPM information include atleast one of an MPM flag, an MPM index, an MPM list, and an MPMcandidate. For example, when the MPM flag for the intra prediction modeof the current block indicates matching, the indicator mrl_index may besignaled. Alternatively, when any one directional prediction mode ispresent within an MPM candidate list or only directional predictionmodes are present within the MPM candidate list, the indicator mrl_indexmay be signaled. Alternatively, when any one non-directional predictionmode is present in the MPM candidate line, the indicator mrl_index maybe signaled. Alternatively, the MPM information of the current block issignaled differently depending on the indicator mrl_index. For example,when the indicator mrl_index has a value other than 0, at least onepiece of the MPM information may not be signaled. For example, when theindicator mrl_index has a value other than 0, the MPM flag or theremaining mode information may not be signaled. On the other hand, whenthe indicator mrl_index has a value other than 0, the MPM index may besignaled and the intra prediction mode of the current block may bederived using the MPM index. For example, when the indicator mrl_indexhas a value other than 0, the MPM mode may be determined without parsingthe MPM flag.

For example, when the size (width or height) of the current block iswithin a predetermined size range, the indicator mrl_index may besignaled. For example, when the size (width or height) is larger than apredetermined size (e.g., 4), the indicator mrl_index may be signaled.

For example, the indicator mrl_index may be signaled depending onwhether the current block is located at the upper boundary of a CTU. Forexample, when the current block is located at the upper boundary of aCTU, the indicator mrl_index may not be signaled.

For example, the indictor mrl_index may be signaled when the colorcomponent of the current block is a luminance signal, and the indicatormrl_index indicator may not be signaled when the color component is achrominance signal.

Alternatively, the indicator mrl_index refers to a reference sample lineto be used optionally. For example, the first reference sample lineadjacent to the current block may be always used, and the referencesample line indicated by the indicator mrl_index indicator may beoptionally used.

When multiple reference sample lines are used, whether to applyfiltering is determined for each reference sample line. For example, onthe basis of the intra prediction mode and the block size/shape,filtering may be applied to the first reference sample line adjacent tothe current block but the filtering may not be applied to the second andsubsequent reference sample line around the current block.Alternatively, the filtering may be applied only to one reference sampleline. For example, the filtering may be applied only to either a leftreference sample line or an upper reference sample line. Which referencesample line is subjected to filtering may be determined depending on atleast one of the shape, size, and intra prediction mode of the currentblock. The shape of the current block may be determined depending on asize comparison between the width and the height of the current block ora ratio of the width and the height.

The configured reference sample may be represented as ref[m, n], and asample obtained by applying a filter to the configured reference samplemay be represented as rec[m, n]. Herein, m or n may be a predeterminedinteger value representing a position of a sample. When a position of aleft upper side sample within the current block is (0, 0), a position ofa left upper side reference sample of the current block may be set to(−1, −1).

FIG. 14 is a diagram for describing a plurality of reconstructed samplelines.

A reference sample can be constructed by selecting one or morereconstructed sample lines adjacent to the current block. For example,in FIG. 14, one of the plurality of reconstructed sample lines may beselected so as to construct a reference sample.

For example, a particular reconstructed sample line of the plurality ofreconstructed sample lines may be fixedly or adaptively selected, or anarbitrary reconstructed sample line may be adaptively selected, in orderto construct a reference sample.

In another embodiment, to construct a reference sample, one or morereconstructed sample lines may be selected from the plurality ofreconstructed sample lines illustrated in FIG. 14, and the selectedreconstructed sample lines may be combined.

For example, as shown in Equation 1, a reference sample may beconstructed using a weighted average of reconstructed samples, in whichthe weights of the reconstructed samples differ according to thedistance between the reconstructed sample and the current block.ref[−1,−1]=(rec[−2,−1]+2×rec[−1,−1]+rec[−1,−2]+2)>>2ref[x,−1]=(rec[x,−2]+3×rec[x,−1]+2)>>2, (x=0 to H+W−1)ref[−1,y]=(rec[−2,y]+3×rec[−1,y]+2)>>2, (y=0 to H+W−1)  [Equation 1]

Alternatively, a reference sample may be constructed using at least oneof a mean value, a maximum value, a minimum value, a median value, and amode value of a plurality of reconstructed samples based on at least oneof the distance from the current block to the correspondingreconstructed sample and the intra prediction mode of the current block.

Alternatively, a reference sample may be constructed based on a change(change amount) between each of the sample values of the successivereconstructed samples. For example, a reference sample may beconstructed based on at least one of a determination of whether thevalues of two successive reconstructed samples differ by more than athreshold value and a determination of whether the values of successivereconstructed samples change continuously or discontinuously. Forexample, when the values of a rec[−1, −1] and a rec[−2, −1] differ bymore than a threshold value, the value of the ref[−1, −1] is determinedas having the value of the rec[−1, −1], or a value corresponding to aweighted average obtained by applying a predetermined weight to thevalue of the rec[−1, −1]. For example, each of the values of thesuccessive reconstructed samples changes by n as the distance betweenthe reconstructed sample and the current block decreases, and thus thevalue of ref[−1, −1] is represented as “ref[−1, −1]=rec[−1, −1]−n”.

In a different embodiment, referring to FIG. 14, two or morereconstructed sample lines may be selected to construct a referencesample. For example, two lines including a reconstructed sample line 1and a reconstructed sample line 2 may be fixedly selected, or four linesranging from a reconstructed sample line 1 to a reconstructed sampleline 4 may be selected to construct a reference sample.

Alternatively, two or more reconstructed sample lines may be adaptivelyselected to construct a reference sample. For example, one reconstructedsample line may be fixedly selected, and one or more reconstructedsample lines may be adaptively selected among the other reconstructedsample lines to construct a reference sample.

The fixedly selected reconstructed sample line may be predefined in theencoder/decoder. For the case where the fixedly selected reconstructedsample line is predefined, information on the fixedly selectedreconstructed sample line may not be signaled.

The information on the adaptively selected reconstructed sample line(s)may be signaled in the form of an indicator or index. The adaptivelyselected reconstructed sample line may be determined based on at leastone of coding parameters of the current block or a block neighboring thecurrent block. For example, the adaptively selected reconstructed sampleline may be determined based on at least one of the size/shape and intraprediction mode of the current block or the block neighboring thecurrent block. In this case, the information necessary for selection maynot be signaled.

A reference sample line may include one or more samples. For example,the reference sample line may include samples corresponding to a lengthequal to the width (that is, the horizontal dimension) or height (thatis, the vertical dimension) of the current block. As another example,the reference sample line may include samples corresponding to a lengththat is two times the width or height of the current block. As a furtherexample, the reference sample line may include samples corresponding toa length equal to N samples (N is 1, 2, 3, . . . ) plus two times thesum of the width and height of the current block. That is, the referencesample line may include reference samples corresponding to 2×(W+H)+N(where W and H are the width and height of the current block, and N isan integer of 1 or more).

The method of constructing a reference sample adjacent to an upper partof the current block and the method of constructing a reference sampleadjacent to a left part of the current block may differ. For example,the number of reference sample lines located above the current block andthe number of reference sample lines located to the left of the currentblock may differ. For example, the number of reference sample linesadjacent to the upper part of the current block may be one and thenumber of reference sample lines adjacent to the left part of thecurrent block may be two, according to at least one of the width orheight of the current block, and the intra prediction mode of thecurrent block. For example, the length of the reference sample lineabove the current block and the length of the reference sample linelocated to the left of the current block may differ. For example, thelength of the reference sample line may vary according to at least oneof the width or height of the current block and the intra predictionmode of the current block.

Each of the reference sample lines may have a different length. Forexample, referring to FIG. 14, the lengths of the reconstructed samplelines 2 to 4 may be longer than the reconstructed sample line 1 by alength corresponding to one or more samples.

The length of the reference sample line may be different for each of thereconstructed sample lines. For example, a reconstructed sample line nmay be longer or shorter than a reconstructed sample line n−1 by alength corresponding to m samples. In the example illustrated in FIG.14, the reconstructed sample line n is longer than the reconstructedsample line n−1 by a length corresponding to one sample.

As described above, decision information on whether to construct areference sample using only the nearest reference sample line or using aplurality of reference sample lines may be encoded/decoded. For example,the decision information may be encoded/decoded at the level of at leastone of a sequence, a picture, a slice, a tile, a CTU, a CU, a PU, and aTU. In addition, information on the availability of each of theplurality of reference sample lines may be signaled at a higher level.

At least one of the number, position, and configuration of thereconstructed sample lines used in the reference sample construction maybe differently set when the top boundary or the left boundary of thecurrent block corresponds to the boundary of at least one of a picture,a slice, a tile, and a coding tree block (CTB). For example, when two ormore reference sample lines are constructed, when the top boundary ofthe current block corresponds to the boundary of at least one of apicture, a tile, a slice, and a coding tree block (CTB), one referencesample line adjacent to the upper part of the current block may beconstructed. For example, one reference sample line may be configuredwhen the top boundary of the current block corresponds to the topboundary of a CTU, and otherwise, two or more reference sample lines maybe configured. In this case, since only one reference sample line at thetop boundary of the CTU is used, the size of a line buffer for storingdata of the reference samples of the reference sample line can bereduced.

When selecting a reference sample, availability determination andreference sample padding may be performed for a block containing thereference sample to be used. For example, when a block containing areference sample is available, the corresponding reference sample can beused. On the other hand, when a block containing a reference sample isnot available, the unavailable reference samples in the block may bepadded with one or more available neighboring reference samples.

When a reference sample is located outside the boundary of at least oneof a picture, a tile, a slice, or a coding tree block (CTB), thereference sample may be determined to be unavailable. When the currentblock is coded with constrained intra prediction (CIP), in the casewhere the block including the reference sample has been encoded/decodedin an inter prediction mode, the reference sample is determined to beunavailable.

FIG. 15 is a diagram for describing a process of replacing anunavailable sample with an available sample.

When it is determined that the reconstructed neighboring sample is notavailable, the unavailable sample may be replaced with a reconstructedneighboring sample, which is an available sample. For example, whenthere are both available samples and unavailable samples as illustratedin FIG. 15, one or more available samples can be used to replace one ormore unavailable samples.

The sample values of the unavailable samples may be replaced with thevalues of the available samples in a predetermined order. The availablesamples used to replace the unavailable samples may be available sampleslocated adjacent to the unavailable samples. When no available sample isadjacent to the unavailable sample, the earliest or closest availablesample may be used to replace the unavailable sample. The replacingorder of the unavailable samples may be, for example, from the bottomleft to the top right. Alternatively, the replacing order may be fromthe top right to the bottom left. Specifically, the replacing order maybe from the top left corner to the top right and/or to the bottom left.Alternatively, the replacing order may be from the top right and/or fromthe bottom left to the top left corner.

For example, filling the unavailable samples with the values ofavailable samples may start from the position 0, which is the bottomleft sample position. That is, the first four unavailable samples may befilled with a value of “a”, and the subsequent 13 unavailable samplesmay be filled with a value of “b”.

For example, the unavailable samples may be filled with a combined valueof the available samples. For example, the unavailable samples may befilled with an average value or an interpolated value of the availablesamples respectively adjacent to both ends of a line of the unavailablesamples. That is, the first four unavailable samples are filled with thevalue “a”, and the next 13 unavailable samples may be filled with theaverage of a value of “b” and a value of “c”, or may be filled byinterpolating the value “b” and the value “c”.

Alternatively, the 13 unavailable samples may be filled with anarbitrary intermediate value between the sample values “b” and “c” ofthe available samples. In this case, the unavailable samples may befilled with different respective values. For example, as the distance ofan unavailable sample to the available sample having the value “a”decreases, the unavailable sample will be filled with a value that iscloser to the value “a”. For example, the closer an unavailable sampleis to an available sample having the value “b”, the closer the valuethat fills the unavailable sample is to the value “b”. That is, thevalue of an unavailable sample may be determined based on the distancebetween the unavailable sample and the available sample having the value“a” or “b”. To replace unavailable samples with available samples, oneor more replacement methods including the methods described above may beadaptively used. The method of replacing unavailable samples withavailable samples may be signaled as information contained in abitstream, or may be predetermined in the encoder/decoder.Alternatively, a replacement method may be derived according to apredetermined determination method. For example, the replacement methodmay be determined based on the difference between the values “a” and “b”or based on the number of unavailable samples. More specifically, thereplacement method may be determined by comparing the difference betweenthe values of two available samples with a threshold value and/or bycomparing the number of unavailable samples with a threshold value. Forexample, when the difference between the values of the two availablesamples is greater than the threshold value, and/or when the number ofunavailable samples is greater than the threshold value, the unavailablesamples may be replaced to have different values from each other. Theselection of the method of replacing unavailable samples with availablesamples may be performed on a per-predetermined-unit basis. For example,the replacement may be selected on a per-video basis, a per-sequencebasis, a per-picture basis, a per-slice basis, a per-tile basis, aper-coding-tree-unit (CTU) basis, a per-coding-unit (CU) basis, aper-prediction-unit (PU) basis, a per-transform-unit (TU) basis, or aper-block basis. At this time, the selection of the method of replacingunavailable samples with available samples may be determined based onthe information signaled on a per-predetermined-unit basis or may bederived on a per-predetermined-unit basis. Alternatively, the selectionmethod for the replacement methods may be predetermined in theencoder/decoder.

When a reference sample is located at a predetermined position, paddingmay be automatically performed without determining whether a blockincluding the reference sample is available or not. For example,referring to FIG. 15, when the position (x, y) of the top left cornersample of the current block is (0, 0), sample availability may not bedetermined for samples located at (x, y) in which the x coordinate orthe y coordinate is equal to or greater than W+H (x=W+H or greater ory=W+H or greater), and the samples may be padded with neighboringreference samples.

For example, a sample ref[W+H, −2] may be padded with the value of asample ref[W+H−1, −2] without performing the availability determinationon the sample ref[W+H, −2]. As another example, a sample ref[W+H, −3]and a sample ref[W+H+1, −3] may be padded with the value of a sampleref[W+H−1, −3] without performing the availability determination on thesample[W+H, −3] and the sample ref[W+H+1, −3]. That is, the padding maybe performed on the samples located at position (x, y) where x is equalto or greater than W+H or y is equal to or greater than W+H, by usingthe closest sample on the same sample line without performing theavailability determination thereon.

When the position of the top left corner sample of the current block is(0, 0), for samples located at position (x, y) where x is equal to orgreater than W and is less than W+H, among the samples located above thecurrent block, the availability determination will be performed, andthen the padding will be performed according to the result of theavailability determination. For samples located at position (x, y) wherey is equal to or greater than H and is less than W+H, among the sampleslocated to the left of the current block, the availability determinationwill be performed, and the padding will be performed according to theavailability determination.

For example, when the position of the top left corner sample of thecurrent block is (0, 0), for samples corresponding to rec[x, −1] (xranges from −1 to W+H−1) and/or samples corresponding to rec[−1, y](yranges from 0 to H+W−1), the availability determination and the paddingmay be performed.

For the padding, a plurality of reference sample lines may be used. Forexample, when the padding is performed on a first reference sample lineadjacent to (that is, the closest to) the current block, a secondreference sample line, which is the second closest to the current block,may be used. For example, the padding may be performed according toEquation 2. That is, the sample values of the first reference sampleline may be derived by using the weighted average of samples selectedfrom the first reconstructed reference sample line and samples selectedfrom the second reconstructed reference sample line. In this case, theselected reconstructed sample may be one located at a current sampleposition or at a position adjacent to the current sample position.ref[x,−1]=(rec[x,−2]+3×rec[x,−1]+2)>>2, (x=0˜H+W−1)  [Equation 2]

Filtering may be performed on one or more reference samples among thesamples constructed as above. The filtering may be adaptively performedbased on at least one of the intra prediction mode of the current block,the size of the current block, and the shape of the current block. Forexample, at least one of a determination of whether to apply filtering,a filter type, a filter strength, and a filter coefficient may beadaptively determined.

For example, whether to apply the filtering may be determined for eachof the plurality of reference sample lines. For example, the filteringmay be applied to the first reference sample line adjacent to thecurrent block, and may not be applied to the second reference sampleline. For example, both a filtered value and an unfiltered value may beused for the same reference sample.

For example, at least one of a 3-tap filter, a 5-tap filter, a 7-tapfilter, and an N-tap filter may be selectively applied according to atleast one of the intra prediction mode of the current block, the size ofthe current block, and the shape of the current block. In this case, Mis an integer equal to or greater than 3.

For example, filters having different shapes may be selectively usedaccording to at least one of the intra prediction mode, the size, andthe shape of the current block. FIG. 16 illustrates various filtershapes.

The shape of the current block may be determined by comparing the width(horizontal dimension) of the current block with the height (verticaldimension) of the current block. For example, at least one of a decisionof whether to apply a filter, a filter type, a filter strength, and afilter coefficient may be adaptively determined according to whether thecurrent block is a horizontally oblong block or a vertically oblongblock. Alternatively, at least one of a decision of whether to applyfiltering, a filter type, a filter strength, and a filter coefficientmay be adaptively determined according to whether the current block is arectangular block or a square block.

Intra prediction for the current block may be performed based on thederived intra prediction mode and the constructed reference sample.

For example, non-directional intra prediction may be performed for thecurrent block. The mode of the non-directional intra prediction may beat least one of a DC mode, a planar mode and an LM mode.

For the DC mode, prediction may be performed using the average value ofone or more reference samples among the constructed reference samples.In this case, filtering may be applied to one or more prediction samples(also referred to as predicted samples) located at the boundary of thecurrent block. The DC prediction may be adaptively performed based on atleast one of the size of the current block and the shape of the currentblock. Further, the range of the reference samples used in the DC modecan be determined based on at least one of the size and the shape of thecurrent block.

FIG. 17 is a diagram for describing intra prediction according to theshapes of the current block.

For example, when the current block is a square block, as illustrated in(a) of FIG. 17, DC prediction may be performed by using the averagevalue of the reference sample located above the current block and thereference sample located to the left of the current block.

For example, when the current block is a non-square block, neighboringsamples adjacent to the left end and the upper end of the current blockmay be selectively used. When the current block is a rectangular block,as illustrated in (b) of FIG. 17, the prediction may be performed usingthe average value of the reference samples adjacent to a longer sideamong the left side and the upper side of the current block.

For example, when the size of the current block corresponds to apredetermined size or falls within a predetermined range, apredetermined number of reference samples, among the reference sampleslocated above or to the left of the current block, are selected, and theprediction is performed using the average value of the selectedreference samples. The predetermined size may be a fixed size of N×M,which is preset in the encoder/decoder. In this case, N and M areintegers greater than 0, and N and M may be the same or different fromeach other. The predetermined range may mean a threshold value forselecting the reference samples for prediction of the current block. Thethreshold value may be set with at least one of a minimum value and amaximum value. The minimum value and/or the maximum value may be a fixedvalue or fixed values preset in the encoder/decoder, or a variable valueor variable values that is/are encoded and then signaled by the encoder.

For example, one or more average values may be used to perform theprediction. When the current block is a square block or a non-squareblock, at least one of a first average value or a second average valuemay be used, in which the first average value is the average of thereference samples located above the current block and the second averagevalue is the average of the reference samples located to the left of thecurrent block. The DC prediction value of the current block may be thefirst average value or the second average value. Alternatively, the DCprediction value of the current block may be a weighted sum obtained byweighting the first average value and the second average value. Forexample, the weights for the first and second average values may be thesame (that is, 1:1).

According to the above method, a shift operation can be used tocalculate all of the DC values. For example, the method can be used evenfor the case where a sample length, which represents the width, theheight, or the sum of the width and height of the current block, is notthe power of two. The method may be applied to both luma DC predictionand chroma DC prediction. Alternatively, the method may be appliedeither to luma DC prediction or to chroma DC prediction.

For example, when the current block is a non-square block, theprediction may be performed based on either the width or the height ofthe current block. For example, a predicted value may be obtained bydividing the sum of the values of the upper reference sample and theleft reference sample by the length of a longer side (namely, the widthor the height) of the current block. In this case, the divisionoperation using the value corresponding to the longer one among thewidth and the height may be performed by a shift operation.

For example, the DC prediction may be performed using a plurality ofreference sample lines. For example, the prediction may be performedusing two reference sample lines, as illustrated in (c) of FIG. 17.

For example, the average value of the reference samples included in thetwo reference sample lines may be determined as the DC prediction valueof the current block.

Alternatively, different weights may be applied to the reference samplesof the first adjacent line and the reference samples of the secondadjacent line of the current block. For example, a weighted average ofeach sample in the first reference sample line and each sample in thesecond reference sample line is calculated by applying the weights 3:1to each sample in the first reference sample line and each sample in thesecond reference sample line (that is, (3× the first line referencesample+the second line reference sample+2)>>2), and the average of theweighted averages may be determined as the DC prediction value of thecurrent block. Alternatively, the resultant value of ((3× the first linereference sample−the second line reference sample)>>1) may be obtained,and the average of these values may be determined as the DC predictionvalue of the current block. The weights are not limited to the aboveexample, and any weights may be used. In this case, the closer to thecurrent block the reference sample line is, the larger the weight thatis applied to the reference sample line. The number of reference samplelines that can be used is not limited to two, and three or morereference sample lines may be used for prediction.

For the planar mode, prediction may be performed with a weighted sum asa function of the distance from at least one reference sample to anintra prediction target sample located in the current block.

Filtering may be performed on reference samples of the current block orprediction samples (that is, predicted samples) of the current block.For example, after filtering is applied to reference samples, planarprediction may be performed, and then filtering may be performed on oneor more prediction samples. Among the prediction samples, filtering maybe performed on samples in one, two, or N sample lines located at thetop boundary or the left boundary of the current block.

To perform the planar prediction, a weighted sum of one or morereference samples may be used. For example, five reference samples maybe used, as illustrated in (d) of FIG. 17. For example, to generate aprediction sample for a target position [x, y], the reference samplesr[−1, −1], r[x, −1], r[−1, y], r[W, −1], and r[−1, H] may be used. Inthis case, W and H are the width and the height of the current block,respectively. For example, prediction samples pred[x, y] can begenerated using Equation 3. In Equation 3, a, b, c, d, and e representweights. N may be log₂ (a+b+c+d+e).pred[x,y]=(a×r[−1,−1]+b×r[x,−1]+c×r[−1,y]+d×r[W,−1]+e×r[−1,H])>>N  [Equation3]

As another example, the planar prediction may be performed using aplurality of reference sample lines. For example, the planar predictionmay be performed using a weighted sum of two reference sample lines. Asanother example, the planar prediction may be performed using a weightedsum of reference samples in the two reference sample lines. In thiscase, the reference samples selected from the second reference sampleline may be samples adjacent to the reference samples selected from thefirst reference sample line. That is, when the reference sample locatedat the position (−1, −1) is selected, the reference sample located atthe position (−2, −2) may be selected. The planar prediction may beperformed by calculating a weighted sum of the selected referencesamples, and in this case the same weights as those used for the DCprediction may be used.

A directional prediction mode refers to at least one of a horizontalmode, a vertical mode, and an angular mode having a predetermined angle.

In the horizontal mode or the vertical mode, prediction is performedusing one or more reference samples arranged in a linear direction,i.e., in the horizontal direction or the vertical direction. A pluralityof reference sample lines may be used. For example, when two referencesample lines are used, prediction may be performed using two referencesamples arranged in a horizontal line or a vertical line. Similarly,when N reference sample lines are used, N reference samples in ahorizontal line or a vertical line may be used.

For the vertical mode, the statistics of a first reference sample (e.g.,r[x, −1]) on a first reference sample line and a second reference sample(e.g., r[x, −2]) on a second reference sample line may be used toperform the directional prediction.

For example, the predicted value of the vertical mode can be determinedby calculating the result value of (3×r[x, −1]+r[x, −2]+2)>>2.Alternatively, the predicted value of the vertical mode can bedetermined by calculating the result value of (3×r[x, −1]−r[x,−2]+1)>>1. In yet another alternative, the predicted value of thevertical mode can be determined by calculating the value of (r[x,−1]+r[x, −2]+1)>>1.

For example, the change between each of the sample values on thevertical line may be considered. For example, the predicted value of thevertical mode can be determined by calculating the result value of (r[x,−1]+(r[x, −1]−r[x, −2])>>1). In this case, N may be an integer equal toor greater than 1. As N, a fixed value may be used. Alternatively, N mayincrease with an increase in the y coordinate of a prediction targetsample. For example, N=y+1.

Even for the horizontal mode, one or more methods used for the verticalmode can be used.

For an angular mode of a certain angle, prediction may be performedusing one or more reference samples arranged in an oblique directionfrom an intra prediction target sample of the current block, or one ormore samples neighboring the reference samples located in the obliquedirection. In this case, a total of N reference samples may be used,wherein N may be 2, 3, 4, 5, or 6. It is also possible to performprediction by applying at least one of an N-tap filter to the Nreference samples. Examples of the N-tap filter include a 2-tap filter,a 3-tap filter, a 4-tap filter, a 5-tap filter, and a 6-tap filter. Atthis time, at least one of the reference samples may be located abovethe current block and the rest may be located to the left of the currentblock. The reference samples located above the current block (or thereference samples located to the left of the current block) may belocated in the same line or in different lines.

According to another embodiment, intra prediction may be performed basedon position information. In this case, the position information may beencoded/decoded, and a reconstructed sample block located at theposition described above may be derived as an intra predicted block ofthe current block. Alternatively, a block similar to the current blockmay be searched for by the decoder, and the found block may be derivedas the intra predicted block of the current block. The searching for asimilar block may be performed in an encoder or a decoder. The range(search range) in which the search is performed may be limited to apredetermined range. For example, the search range may be limited toreconstructed sample blocks within a picture in which the current blockis included. Alternatively, the search range may be limited to a CTU inwhich the current block is included or to a predetermined CU. That is,location information-based intra prediction may be performed bysearching for a block similar to the current block among reconstructedsamples within a CTU. The searching may be performed using a template.For example, one or more reconstructed samples adjacent to the currentblock are taken as a template, and a CTU is searched for samples similarto the template.

The location information-based intra prediction may be performed whenthe CTU consists of only intra coding modes or when the luminance blockand the chrominance block have different partition structures. Forexample, for an inter prediction available slice (e.g., P or B slice),information indicating that the current CTU consists of only intracoding modes may be signaled. In this case, when the informationindicates that a current CTU consists of only intra coding modes, thelocation information-based intra prediction may be performed.Alternatively, when the luminance block and the chrominance block in thecurrent CTU have different partition structures (for example, whendual_tree or separate_tree is a value of 1), the locationinformation-based intra prediction may be available. On the other hand,when a CTU includes intra coding blocks and inter coding blocks or whenthe luminance block and the chrominance block have the same partitionstructure, location information-based intra prediction may not beavailable.

According to a further embodiment, inter color component intraprediction is performed. For example, it is possible to intra-predictchroma components from the corresponding reconstructed luma component ofthe current block. Alternatively, it is possible to intra-predict onechroma component Cr from the corresponding reconstructed chromacomponent Cb of the current block.

An inter color component intra prediction includes a color componentblock restructuring step, a prediction parameter deriving step, and/oran inter color component prediction execution step. The term ‘colorcomponent’ may refer to at least any one of a luma signal, a chromasignal, Red, Green, Blue, Y, Cb, and Cr. A prediction of a first colorcomponent can be performed by using at least any one of a second colorcomponent, a third color component, and a fourth color component. Thesignals of the color components used for the prediction may include atleast any one of an original signal, a reconstructed signal, a residualsignal, and a prediction signal.

When performing an intra prediction for a second color component targetblock, a sample of a first color component block corresponding blockthat corresponds to the second color component target block, a sample ofa neighbor block of the first color component corresponding block, orboth of the samples may be used. For example, when performing an intraprediction for a chroma component block Cb or Cr, a reconstructed lumacomponent block Y corresponding to the chroma component block Cb or Crmay be used.

When predicting the chroma components on the basis of the lumacomponent, the prediction may be performed according to Equation 4.Pred_(C)(i,j)=α·rec_(L)′(i,j)+β  [Equation 4]

In Equation 4, Pred_(C)(i, j) represents a predicted chroma sample ofthe current block, and rec_(L)(i, j) represents a reconstructed lumasample of the current block. At this time, rec_(L)′(i, j) may be adown-sampled reconstructed luma sample. Parameters α and β may bederived by minimizing a regression error between the reconstructedneighboring luma sample and the reconstructed neighboring chroma samplearound the current block.

There are two modes for predicting the chroma components using the lumacomponent. The two modes may include a single-model mode and amultiple-model mode. The single-model mode may use one linear model whenpredicting the chroma components from the luma components for thecurrent block. The multiple-model mode may use two linear models.

In the multiple-model mode, the samples adjacent to the current block(that is, adjacent luma samples and adjacent chroma samples) may beclassified into two groups. That is, the parameters α and β for each ofthe two groups may be derived. Further, the luma samples of the currentblock may be classified according to the rules used for classificationof the luma samples adjacent to the current block.

For example, a threshold value for classifying the adjacent samples intotwo groups may be calculated. The threshold value may be calculatedusing an average value of the reconstructed adjacent luma samples.However, the calculation of the threshold value is not limited thereto.At least one of various statistical values recognized in the presentspecification may be used instead of the average value. When the valuesof the adjacent samples are larger than the threshold value, theadjacent samples may be classified into a first group. Otherwise, theadjacent samples may be classified into a second group.

Although it is described that the multiple-model mode uses two linearmodes in the embodiment described above, the present invention is notlimited thereto, and may cover other cases in which two or more linearmodels are used. When N linear models are used, samples may beclassified into N groups. To do so, N−1 threshold values may becalculated.

As described above, when predicting a chroma component from a lumacomponent, a linear model can be used. In this case, the linear modelmay include a simple linear model (hereinafter referred to as “LM1”), acomplex linear model (hereinafter referred to as “LM2”), and a complexfilter linear model (hereinafter, referred to as “LM3”). Parameters ofthe models described above may be derived by minimizing regression errorbetween the reconstructed luma samples around the current block and thecorresponding reconstructed chroma samples around the current block.

FIG. 18 is a diagram for describing “neighboring samples of a currentblock” (hereinafter referred to as “adjacent data set”) used to derivethe parameters of the models.

The adjacent data set for deriving the parameters of the LM1 may becomposed of a pair of samples comprising a luma sample and a chromasample in each of a line area B and a line area C illustrated in FIG.18. The adjacent data set for deriving the parameters of the LM2 and LM3may be composed of a pair of samples comprising a luma sample and chromasample in each of a line area B, a line area C, a line area E, and aline area F illustrated in FIG. 18.

However, the adjacent data set is not limited to the examples describedabove. For example, to cover various linear relationships between lumaand chroma samples in the current block, N adjacent data sets may beused for each mode. For example, N may be an integer of 2 or more, andspecifically 3.

The parameters of the linear model may be calculated using both an uppertemplate and a left template. Alternatively, there are two LM modes (anLM_A mode and an LM_L mode), and the upper template and the lefttemplate may be used in the LM_A mode and the LM_L mode, respectively.That is, in the LM_A mode, the linear model parameters may be obtainedusing only the upper template. When the position of the upper leftcorner sample of the current block is (0, 0), the upper template may beextended to a range from (0, −n) to (W+H−1, −n). In this case, n is aninteger equal to or greater than 1. That is, in the LM_L mode, thelinear model parameters may be obtained using only the left template.The left template may be extended to a range from (−n, 0) to (−n,H+W−1). In this case, n is an integer equal to or greater than 1.

A power of two numbers of samples can be used to derive the parametersof the linear model. When the current chroma block is a non-squareblock, the samples used to derive the parameters of the linear model maybe determined based on the number of samples on a shorter side, amongthe horizontal side and the vertical side of the current block.According to one embodiment, when the size of the current block is n×m(where n>m), m samples of the n adjacent samples adjacent to the topboundary of the current block may be selected, for example, byperforming sub-sampling uniformly. In this case, the number of samplesused to derive the parameters of the linear model may be 2 m. As anotherexample, when the size of the current block is n×m (where n>m), msamples of the n adjacent samples adjacent to the top boundary of thecurrent block may not be used. For example, of the n samples, m samplesthat are farthest from the shorter one of the horizontal side and thevertical side of the current block may not be used. In this case, thenumber of samples used to derive the parameters of the linear model maybe n (n−m samples adjacent to the top boundary of the current block+msamples adjacent to the left boundary of the current block).

Alternatively, when performing an intra prediction for a chromacomponent block Cr, a chroma component block Cb may be used.Alternatively, when performing an intra prediction for a fourth colorcomponent block, at least one of a first color component block, a secondcolor component block, and a third color component, all of whichcorrespond to the fourth color component block, may be used.

Whether or not to perform an inter color component intra prediction maybe determined based on at least any one of the size and the shape of acurrent target block. For example, when the size of the target block isequal to that of a coding tree unit (CTU), larger than a predeterminedsize, or within a predetermined size range, the inter color componentintra prediction for the target block can be performed. Alternatively,when the shape of the target block is a predetermined shape, the intercolor component intra prediction for the target block can be performed.The predetermined shape may be a square shape. In this case, when thetarget block has an oblong shape, the inter color component intraprediction for the target block may not be performed. Meanwhile, whenthe predetermined shape is an oblong shape, the embodiment describedabove inversely operates.

Alternatively, whether or not to perform an inter color component intraprediction for a prediction target block may be determined based on acoding parameter of at least any one block selected from among acorresponding block corresponding to the prediction target block andneighbor blocks of the corresponding block. For example, when thecorresponding block has been predicted through an intra predictionmethod in a constrained intra prediction (CIP) environment, an intercolor component intra prediction for the prediction target block may notbe performed. Alternatively, when the intra prediction mode of thecorresponding block is a predetermined mode, an inter color componentintra prediction for the prediction target block can be performed.Further alternatively, whether or not to perform an inter colorcomponent intra prediction may be determined on the basis of at leastany one of CBF information of the corresponding block and CBFinformation of the neighbor blocks thereof. The coding parameter is notlimited to a prediction mode of a block but various parameters that canbe used for encoding/decoding may be used.

The color component block restructuring step will be described below.

When predicting a second color component block by using a first colorcomponent block, the first color component block may be restructured.For example, when an image has an YCbCr color space and when a samplingratio of color components is one of 4:4:4, 4:2:2, and 4:2:0, the blocksizes of color components may differ from each other. Therefore, whenpredicting a second color component block using a first color componentblock having a different size from the second color component block, thefirst color component block may be restructured such that the blocksizes of the first color component and the second color component areequalized. The restructured block may include at least any one of asample in the first color component block that is a corresponding blockand a sample in a neighbor block of the first color component block.

FIG. 19 is an exemplary diagram illustrating a process of restructuringa color component block.

In FIG. 19(a), p1[x, y] represents a sample at a position (x, y) in thefirst color component block. In FIG. 19(b), p1′ [x, y] represents asample at a position (x, y) in the restructured block that is producedby restructuring the first color component block.

When the first color component block has a larger size than the secondcolor component block, the first color component block is down-sampledto have a size equal to that of the second color component block. Thedown-sampling may be performed by applying an N-tap filter to one ormore samples (N is an integer equal to or larger than 1). For thedown-sampling, at least any one equation of Equation 5 to Equation 9 maybe used. In the case in which any one down-sampling method among variousdown-sampling methods is selectively used, an encoder may select onedown-sampling method as a predetermined down-sampling method. Forexample, the encoder may select a down-sampling method having optimaleffects. The selected down-sampling method is encoded and signaled to adecoder. The signaled information may be index information indicatingthe down-sampling method.p1′[x,y]=(p1[2x,2y]+p1[2x,2y+1]+1)>>1  [Equation 5]p1′[x,y]=(p1[2x+1,2y]+p1[2x+1,2y+1]+1)>>1  [Equation 6]p1′[x,y]=(p1[2x−1,2y]+2x p1[2x,2y]+p1[2x+1,2y]+2)>>2  [Equation 7]p1′[x,y]=(p1[2x−1,2y+1]+2*p1[2x,2y+1]+p1[2x+1,2y+1]+2)>>2  [Equation 8]p1′[x,y]=(p1[2x−1,2y]+2*p1[2x,2y]+p1[2x+1,2y]+p1[2x−1,2y+1]+2*p1[2x,2y+1]+p1[2x+1,2y+1]+4)>>3  [Equation9]

The down-sampling method performed with respect to two or more samplesis not limited to any one of the examples of Equation 5 to Equation 9.For example, two or more samples used to calculate a down-sampled valuep1′[x, y] may be selected from a sample group consisting of a samplep1[2x, 2y] and neighbor samples thereof. The neighbor samples may beones selected among p1[2x−1, 2y−1], p[2x−1, 2y], p1[2x−1, 2y+1], p1[2x,2y−1], p1[2x, 2y+1], p1[2x+1, 2y−1], p1[2x+1, 2y], and p1[2x+1, 2y+1].The down-sampling can be performed by calculating the average or theweighted average of two or more samples.

Alternatively, the down-sampling may be performed in a manner ofselecting a specific sample among one or more samples. In this case, atleast any one of the following equations, Equation 10 to Equation 13,may be used for the down-sampling.p1′[x,y]=p1[2x,2y]  [Equation 10]p1′[x,y]=p1[2x,2y+1]  [Equation 11]p1′[x,y]=p1[2x+1,2y]  [Equation 12]p1′[x,y]=p1[2x+1,2y+1]  [Equation 13]

When the first color component block has a smaller size than the secondcolor component block, the first color component block is up-sampled tobe restructured such that the sizes of the first color component blockand the second color component block are equalized. In this case, theup-scaling is performed according to Equation 14.p1′[2x,2y]=p1[x,y],p1′[2x+1,2y]=(p1[x,y]+p1[x+1,y]+1)>>1,p1′[2x,2y+1]=(p1[x,y]+p1[x,y+1]+1)>>1,p1′[2x+1,2y+1]=(p1[x+1,y]+p1[x,y+1]+1)>>1  [Equation 14]

In the restructuring process, a filter may be applied to one or moresamples. For example, the filter may be applied to one or more samplesincluded in at least any one of the first color component block (i.e.corresponding block), neighbor blocks of the corresponding block, thesecond color component block (i.e. target block), and neighbor blocks ofthe target block.

In the reference sample restructuring step described above, an indicatorcorresponding to a predetermined reference sample line among a pluralityof reference sample lines may be signaled. In this case, in therestructuring process, the restructuring is performed using thepredetermined reference sample line corresponding to the signaledindicator. For example, when the indicator mrl_index has a value of 0,the reconstruction process is performed using the first and secondreference sample lines adjacent to a first color component correspondingblock. Alternatively, when the indicator mrl_index has a value of 1, thereconstruction process is performed using the second and third referencesample lines adjacent to the first color component corresponding block.Alternatively, when the indicator mrl_index has a value of 3, thereconstruction process is performed using the third and fourth referencesample lines adjacent to the first color component corresponding block.A reference sample line indicated by the indicator mrl_index may be usedfor a second color component target block.

In the restructuring process, when a boundary of the second colorcomponent block (target block) or a boundary of the first colorcomponent block (corresponding block) is a boundary of a predeterminedregion, the reference samples used for the restructuring may bedifferently selected. In this case, the number of reference sample linesat the upper side may differ from the number of reference sample linesat the left side. The predetermined region may be at least any one of apicture, a slice, a tile, a CTU, and a CU.

For example, when the upper boundary of the first color componentcorresponding block is the boundary of the predetermined region, thereference samples at the upper side may not be used for therestructuring but only the reference samples at the left side may beused for the restructuring. When the left boundary of the first colorcomponent corresponding block is the boundary of the predeterminedregion, the reference samples at the left side may not be used for therestructuring but only the reference samples at the upper side may beused for the restructuring. Alternatively, both of N reference samplelines at the upper side and M reference sample lines at the left sidemay be used for the restructuring, in which N may be smaller than M. Forexample, when the upper boundary corresponds to the boundary of thepredetermined region, N may be 1. Meanwhile, when the left boundarycorresponds to the boundary of the predetermined region, M may be 1.

Alternatively, the restructuring may be performed by using N referencesample lines at the upper side and M reference left sample lines at theleft side of the first color component corresponding block, regardlessof whether the boundary of the predetermined region is the upperboundary or the left boundary of the first color component block.

FIG. 20 is a diagram illustrating an embodiment performing restructuringby using a plurality of upper-side reference sample lines and/or aplurality of left-side reference sample lines.

As illustrated in FIG. 20(a), the restructuring may be performed usingfour upper-side reference sample lines and four left-side referencesample lines.

For example, when the upper boundary or the left boundary of the firstcolor component corresponding block is the boundary of the predeterminedregion, the number of the upper-side reference sample lines and thenumber of the left-side reference sample lines used for therestructuring may differ from each other. For example, as illustrated inFIGS. 20(b) to 20(d), any of the following combinations may be used forthe restructuring: two upper-side reference sample lines and fourleft-side reference sample lines; one upper-side reference sample lineand three left-side reference sample lines; and one upper-side referencesample line and two left-side reference sample lines.

The number of reference sample lines used for the restructuring is notlimited to the above combinations. That is, N upper-side referencesamples lines and M left-side reference sample lines may be used inwhich N and M are equal to or different from each other. When both ofthe upper boundary and the left boundary of the corresponding blockcorrespond to the boundary of the predetermined region, N and M may beequal to each other. That is, N and M may be both 1. Alternatively, Nmay be set smaller than M under the same condition. This is because moreresources (memory) are required for the upper-side reference samplelines than for the left-side reference sample lines.

Alternatively, as illustrated in FIG. 20(e), one or more referencesamples within a region having a vertical length and a horizontal lengthnot larger than those of the first color component corresponding blockmay be used for the restructuring.

When performing the restructuring process, the reference samples of thefirst color component corresponding block may be differently setdepending on any one of the block size, the block shape, and the codingparameter of at least any one block selected among the first colorcomponent corresponding block, neighbor blocks thereof, the second colorcomponent target block, and neighbor blocks thereof.

For example, among samples in the first color component correspondingblock and the neighbor blocks thereof, samples in blocks whose encodingmode is an inter frame encoding mode are not used but only samples inblocks whose encoding mode is an intra encoding mode are used for therestructuring.

FIG. 21 is an exemplary diagram illustrating reference samples used forthe restructuring in accordance with an intra prediction mode or acoding parameter of a corresponding block.

The restructuring of the reference samples of the first color componentblock may be differently performed in accordance with the intraprediction modes of the first color component corresponding block. Forexample, when the intra prediction mode of the corresponding block is anon-angular mode, such as a DC mode and a planar mode, or an angularmode in which both of the upper-side reference samples and the left-sidereference samples are used, as illustrated in FIG. 21(a), at least onesample group of the upper-side reference samples and the left-sidereference samples is used for the restructuring. Alternatively, when theintra prediction mode of the corresponding block is an angular mode inwhich both of the upper-side reference samples and the left-sidereference samples of the corresponding block are used, as illustrated inFIG. 21(b), the restructuring of the corresponding block is performedusing at least one sample group of the upper-side reference samples andthe left-side reference samples. Alternatively, when the intraprediction mode of the corresponding block is an angular mode in whichboth of the left-side reference samples and the upper-side referencesamples are used, as illustrated in FIG. 21(c), the corresponding blockmay be restructured using at least any one sample group of the left-sidereference samples and the lower left-side reference samples.

Alternatively, the reference samples used to restructure the first colorcomponent corresponding block are differently selected in accordancewith the quantization parameter of at least any one of the first colorcomponent corresponding block and the neighbor blocks thereof. Forexample, as illustrated in FIG. 21(d), reference samples in an upperblock that is disposed at the upper side of the corresponding block andwhose neighbor blocks have a relatively small quantization parametervalue QP are used for the restructuring of the corresponding block.

Alternatively, when the second color component target block has anoblong shape, reference samples disposed around a first color componentcorresponding block having a square shape are used for therestructuring.

Alternatively, when the second color component target block ispartitioned into two sub-blocks (for example, two 16×8-size sub-blocks)and when the first color component corresponding block is a 32×16-sizeblock, reference samples disposed around a 32×32-size block are used forthe restructuring of the corresponding block. In this case, as referencesamples of the first color component block corresponding to a second16×8-size sub-block disposed at a lower side among the partitioned twosub-blocks of the second color component corresponding block, referencesamples around a restructured 32×32-size block may be shared.

Hereinbelow, the prediction parameter deriving step will be described.

A prediction parameter can be derived using at least any one ofreference samples of the restructured first color componentcorresponding block and reference samples of the second color componentprediction target block. Hereinafter, the terms ‘first color component’and ‘first color component block’ may respectively refer to arestructured first color component and a restructured first colorcomponent block.

FIG. 22 is a diagram illustrating an exemplary restructured first colorcomponent corresponding block when a second color component predictiontarget block is a 4×4 block. In this case, the number of referencesample lines may be N.

The prediction parameter may be derived using reference samples disposedat the upper side and the left side of the restructured first colorcomponent corresponding block or of the second color componentprediction target block as illustrated in the FIG. 22(a).

For example, the prediction parameter can be derived by adaptively usingthe reference samples of the restructured first color component, on thebasis of the intra prediction mode of the first color componentcorresponding block. In this case, the reference samples of the secondcolor component can be adaptively used on the basis of the intraprediction mode of the first color component corresponding block.

When the intra prediction mode of the first color componentcorresponding block is a non-angular mode such as a DC mode or a planarmode, or an angular mode in which both of upper-side reference samplesand left-side reference samples are used, reference samples at the upperside and the left side of the first color component corresponding blockcan be used as illustrated in FIG. 22(a).

When the intra prediction mode of the first color componentcorresponding block is a non-angular mode in which upper-side referencesamples are used, reference samples at the upper side of the first colorcomponent corresponding block may be used as illustrated in FIG. 22(b)or 22(c).

When the intra prediction mode of the first color componentcorresponding block is an angular mode in which left side referencesamples are used, reference samples at the left side of the first colorcomponent corresponding block may be used as illustrated in FIG. 22(d)or 22(e).

Alternatively, when the intra prediction mode of the first colorcomponent corresponding block is an angular mode, reference samples usedin each prediction mode can be used as reference samples of the firstcolor component. For example, when the intra prediction mode is avertical mode, reference samples illustrated in FIG. 22(b) may be used.When the intra prediction mode is a horizontal mode, reference samplesillustrated in FIG. 22(d) may be used. When the intra prediction mode isan up-right diagonal mode, reference samples illustrated in FIG. 22(c)may be used. When the intra prediction mode is a down-left diagonalmode, reference samples illustrated in FIG. 22(e) may be used. When theintra prediction mode is a mode between the vertical mode and theup-right diagonal mode, reference samples illustrated in FIG. 22(f) maybe used. When the intra prediction mode is an angular mode of a 45°diagonal direction, upper right reference samples, lower left referencesamples, or both are used as illustrated in FIG. 22(g). Referencesamples that are differently selected for each intra prediction mode arestored in a format of a look-up table so as to be conveniently used.

The prediction parameter may be derived by adaptively using thereference samples of the first color component or the second colorcomponent in accordance with the size and/or the shape of the firstcolor component block and/or the second color component block.

For example, when the second color component target block has a 64×64size, 32, 16, or 8 reference samples among reference samples at theupper side or the left side of the first color component block or thesecond color component block may be used. As described above, when thesize of the second color component target block is a predetermined size,the reference samples of the first or second color component block maybe adaptively used. The predetermined size is not limited to the 64×64size, but it may be a size signaled through a bitstream or a sizederived on the basis of the coding parameter of a current block or aneighbor block thereof.

Alternatively, when the second color component target block has anoblong shape, reference samples adjacent to a longer side, which is avertical side or a horizontal side, of the second color component targetblock may be used. For example, when the target block has a block sizeof 32×8, reference samples at the upper side of the first colorcomponent or the second color component block may be used.

Alternatively, when the second color component target block has anoblong shape, reference samples around a square block can be used. Forexample, when the target block is a 32×8 block, reference samples arounda 32×32 block can be used.

The prediction parameter can be derived using reference samples aroundthe restructured first color component block and reference samplesaround the second color component block. The prediction parameter can bederived on the basis of any one of the factors including a correlation,a change, an average value, and a distribution of color components. Inthis case, any one of the methods of Least Squares (LS), Least MeanSquares (LMS), etc. may be used.

When deriving the prediction parameters through the LMS method, theprediction parameters may be a and b, α and β, or both. Predictionparameters that can minimize an error between the reference samples ofthe first color component and the reference samples of the second colorcomponent can be derived by Equation 15.

$\begin{matrix}{{E\left( {a,b} \right)} = {\sum\limits_{n = 0}^{N - 1}\left( {{p\; 2_{n}} - \left( {{{a \cdot p}\; 1_{n}^{\prime}} + b} \right)} \right)^{2}}} & \left\lbrack {{Equation}\mspace{14mu} 15} \right\rbrack\end{matrix}$

In Equation 15, p2_(n) represents a reference sample of the second colorcomponent, and p1′_(n) represents a reference sample of the restructuredfirst color component. N is the number of used reference samplesarranged in a vertical direction or a horizontal direction, and a and brepresent prediction parameters.

In this case, a correlation between the reference samples can becalculated by Equation 16.

$\begin{matrix}{\mspace{79mu}{{k = {{Max}\left( {0,{{BitDepth} + {\log\; 2(N)} - 15}} \right)}}\mspace{20mu}{L = {\left( {{\sum\limits_{y = 0}^{N - 1}{p\;{1^{\prime}\left\lbrack {{- 1},y} \right\rbrack}}} + {\sum\limits_{x = 0}^{N - 1}{p\;{1^{\prime}\left\lbrack {x,{- 1}} \right\rbrack}}}} \right) ⪢ k}}\mspace{20mu}{C = {\left( {{\sum\limits_{y = 0}^{N - 1}{p\;{2\left\lbrack {{- 1},y} \right\rbrack}}} + {\sum\limits_{x = 0}^{N - 1}{p\;{2\left\lbrack {x,{- 1}} \right\rbrack}}}} \right) ⪢ k}}\mspace{20mu}{{LL} = {\left( {{\sum\limits_{y = 0}^{N - 1}{p\;{1^{\prime}\left\lbrack {{- 1},y} \right\rbrack}2}} + {\sum\limits_{x = 0}^{N - 1}{p\;{1^{\prime}\left\lbrack {x,{- 1}} \right\rbrack}2}}} \right) ⪢ k}}{{LC} = {\left( {{\sum\limits_{y = 0}^{N - 1}{p\;{1^{\prime}\left\lbrack {{- 1},y} \right\rbrack} \times p\;{2\left\lbrack {{- 1},y} \right\rbrack}}} + {\sum\limits_{x = 0}^{N - 1}{p\;{1^{\prime}\left\lbrack {x,{- 1}} \right\rbrack} \times p\;{2\left\lbrack {x,{- 1}} \right\rbrack}}}} \right) ⪢ k}}}} & \left\lbrack {{Equation}\mspace{14mu} 16} \right\rbrack\end{matrix}$

In Equation 16, BitDepth represents a bit depth. p1′ represent a sampleof the restructured first color component, and p2 represents a sample ofthe second color component.

FIG. 23 is a diagram illustrating a sample of a first color componentand a sample of a second color component.

When there is a region with no reference sample in the process ofderiving a prediction parameter, the prediction parameter can be derivedusing only existing samples.

One or more prediction parameters can be derived. For example, a firstprediction parameter may be derived from reference samples having valuessatisfying a specific requirement among reference samples used to deriveprediction parameters. In addition, a second prediction parameter may bederived from referenced samples having values that do not satisfy thespecific requirement. The specific requirement may be a condition inwhich the value of a reference sample is less than a statistic figure(for example, an average value).

According to another embodiment of the present invention, a basicprediction parameter (default parameter) may be used instead of derivinga prediction parameter from values of reference samples. The defaultparameters may be predefined in the encoder and the decoder. Forexample, the prediction parameters a and b may be respectively 1 and 0.

Alternatively, when deriving prediction parameters from referencesamples, the derived prediction parameters may be encoded and decoded.

When performing an inter color component prediction among colorcomponents Y, Cb, and Cr, prediction parameters used to predict colorcomponents Cb and Cr can be derived from a color component Y. Predictionparameters used to predict a color component Cr can be derived from acolor component Cb. Alternatively, as prediction parameters forpredicting a color component Cr, the prediction parameters that havebeen derived from a color component Y to predict a color component Cbcan be used as they are, instead of deriving new prediction parametersfor a prediction of the color component Cr.

Hereinbelow, the inter color component prediction execution step will bedescribed.

As described above, after prediction parameters are derived, an intercolor component intra prediction can be performed using at least any oneof the derived prediction parameters.

For example, a prediction of a second color component target block canbe performed by applying the derived prediction parameter to areconstructed signal of the restructured first color component,according to Equation 17.p2[x,y]=a×p1′[x,y]+b  [Equation 17]

In Equation 17, p2[x, y] represents a prediction block of the secondcolor component target block. p1′[x, y] represents the first colorcomponent block or the restructured first color component block.

Alternatively, the prediction of the second color component target blockcan be performed by applying the derived prediction parameter to aresidual signal of the restructured first color component, according toEquation 18.p2[x,y]=p2_pred[x,y]+a≤p1′_residual[x,y]  [Equation 18]

In Equation 18, p1′_residual represents a residual signal of the firstcolor component and p2_pred represents a prediction signal obtained byperforming an intra prediction with respect to the second colorcomponent target block.

When the number of the derived prediction parameters is one or more, oneor more prediction parameters may be applied to the reconstructed sampleof the first color component. For example, when the reconstructed sampleof the first color component satisfies a specific requirement, the intercolor component intra prediction may be performed by applying the firstprediction parameter derived from the reference samples that satisfy thespecific requirement. Meanwhile, when the reconstructed sample of thefirst color component does not satisfy the specific requirement, theinter color component intra prediction may be performed by applying thesecond prediction parameter derived from the reference samples that donot satisfy the specific requirement. The specific requirement means acondition that the value of a reference sample is less than a statisticfigure (for example, an average value) of the reference samples of thefirst color component.

The inter color component prediction method may be used in an interprediction mode. For example, when performing the inter prediction onthe current block, inter prediction is performed for a first colorcomponent, and inter color component prediction or prediction combininginter prediction and inter color component prediction may be performedfor a second color component. For example, the first color component maybe a luma component, and the second color component may be a chromacomponent.

The inter-color component prediction may be performed using theprediction sample or the reconstructed sample of the luminancecomponent. For example, after the inter prediction for the luminancecomponent is performed, prediction for a color component may beperformed by applying inter-color component prediction parameters to theprediction sample resulting from the inter prediction of the luminancecomponent. Here, the prediction sample refers to a sample that hasundergone at least one of motion compensation, motion refinement,overlapped block motion compensation (OBMC), and bi-directional opticalflow (BIO).

In addition, the inter color component prediction may be performedadaptively according to the coding parameters of the first colorcomponent. For example, it is possible to determine whether to performinter color component prediction according to CBF information of thefirst color component. The CBF information may be information indicatingwhether a residual signal exists or not. That is, when the CBF of thefirst color component is 1, inter color component prediction may beperformed on the second color component. When the CBF of the first colorcomponent is 0, inter color component prediction may not be performed onthe second color component, and the inter prediction may be performed onthe second color component. Alternatively, a flag indicating whether ornot to perform the inter color component prediction may be signaled.

When coding parameters of the first color component satisfies apredetermined condition, a flag indicating whether to perform theinter-color component prediction may be signaled. For example, when theCBF of the first color component is 1, the flag may be signaled todetermine whether to perform color component prediction.

When performing inter-color component prediction for the second colorcomponent, an inter motion prediction or compensation value for thesecond color component may be used. For example, inter motion predictionor compensation for the second color component may be performed usinginter prediction information of the first color component. In addition,prediction may be performed by calculating the weighted sum of theinter-color component prediction value for the second color componentand the inter motion compensation value.

According to another embodiment of the present invention, templatematching-based prediction may be performed.

When performing the template matching-based prediction, at least oneintra-prediction mode (first intra-prediction mode) is explicitly and/orimplicitly derived for the current block, and a template may begenerated on the basis of the derived intra-prediction mode. Also, atleast one intermediate intra-prediction block is generated on the basisof the second intra-prediction mode, and a prediction block for thecurrent block is finally determined by using a weighted sum between thetemplate and the intermediate intra-prediction block. In this case, thefirst intra-prediction mode and the second intra-prediction mode may bedifferent.

FIG. 24 is a diagram illustrating an embodiment for generating atemplate.

As shown in FIG. 24, the intra-prediction mode N of the current blockmay be explicitly and/or implicitly derived. An intra-prediction blockmay be generated by performing intra-prediction on the basis of thederived intra-prediction mode N, and the intra-prediction blockgenerated may be defined as a template. Herein, N may be zero or apositive integer greater than zero.

In this specification, a template generated in the templatematching-based prediction process may be represented by a firstintra-prediction block, and an intermediate intra-prediction block maybe represented by a second intra-prediction block. In addition, when afinal intra-prediction block of the current block is generated by usinga weighted sum of the first intra-prediction block and the secondintra-prediction block, one or more first intra-prediction blocks and/orsecond intra-prediction blocks may be used.

The intra-prediction mode of the current block may be explicitlyencoded/decoded according to at least one of the various embodimentsdescribed herein. Alternatively, the same intra-prediction mode may beimplicitly derived in the encoder and the decoder. The firstintra-prediction block may be generated using the intra-prediction modeexplicitly or implicitly derived as described above.

Alternatively, the first intra-prediction block may be generated using apredetermined intra-prediction mode in the encoder and the decoder.

The predetermined intra-prediction mode may be a Planar mode or a DCmode.

The predetermined intra-prediction mode may be a plurality ofintra-prediction modes. In this case, a plurality of prediction blockscorresponding to a plurality of intra-prediction modes may be generated,and a first intra-prediction block (template) may be generated by usinga weighted sum of the plurality of intra-prediction blocks generated.For example, after generating two intra-prediction blocks correspondingto the Planar mode and the DC mode, a block obtained by using a weightedsum of the two generated intra-prediction blocks may be defined as atemplate.

In another embodiment, a template may be generated using anintra-prediction mode of at least one neighboring block of neighboringblocks that are spatially adjacent to a current block. In this case, theneighboring block may be a block in which encoding/decoding is completedby using an intra-prediction mode before the current block.

For example, in the example shown in FIG. 11, when at least one of theneighboring blocks L, A, AR, BL, AL, JL, and JA is encoded/decoded usingan intra-prediction mode, it is possible to generate a template using anintra-prediction mode of the corresponding neighboring block.

Alternatively, a predetermined statistical value may be obtained usingone or more intra-prediction modes derived from one or more neighboringblocks, and a template may be generated using an intra-prediction modeindicated by the statistical value. Herein, the statistical value mayinclude at least one of an average value, a maximum value, a minimumvalue, an intermediate value, and a mode value.

Alternatively, after configuring the MPM list for the current block, atemplate may be generated using one or more intra-prediction modesincluded in the MPM list. For example, a template may be generated usingan intra-prediction mode indicated by the first MPM index or anintra-prediction mode having directionality (angular prediction mode) inthe MPM list. When there are a plurality of intra-prediction modeshaving directionality in the MPM list, a template may be generated usingan intra-prediction mode having a smaller MPM index.

An intra-prediction mode for generating a template may be generated byderiving one or more explicit and/or implicit intra-prediction modes.

For example, the intra-prediction mode information transmitted from theencoder may be entropy-encoded/decoded to be explicitly derived, andthen the intra-prediction block A corresponding to the intra-predictionmode may be generated. In addition, the intra-prediction block Bcorresponding to the fixed intra-prediction mode N may be generated, andthen a template may be generated by using a weighted sum of theintra-prediction block A and/or the intra-prediction block B. The fixedintra-prediction modes may be a plurality of intra-prediction modes, andthus a plurality of intra-prediction blocks B may be generated. Thefixed intra-prediction mode may be a Planar mode or a DC mode.

In another example of generating the intra-prediction block B, it ispossible to generate an intra-prediction block B corresponding to anintra-prediction mode of one or more neighboring blocks in whichencoding/decoding is completed using an intra-prediction mode, as ablock spatially adjacent to the current block. The neighboring block maybe a neighboring block L shown in FIG. 11. Alternatively, theneighboring block is not limited thereto, and may be at least one of theneighboring blocks A, AR, BL, AL, JL and JA shown in FIG. 11.

In another embodiment of generating the intra-prediction block B, afterone or more intra-prediction modes are derived from the one or moreblocks shown in FIG. 11, it is possible to generate an intra-predictionblock B corresponding to the statistical value of the derived one ormore intra-prediction modes. The statistical value may be an averagevalue, a median value, a mode value, or the like. However, thestatistical value is not limited to this, and may mean at least one of amaximum value, a minimum value, a weighted average value, and aninterpolation value.

As another example of generating the intra-prediction block B, it ispossible to generate an intra-prediction block B corresponding to atleast one intra-prediction mode included in the MPM list for the currentblock. The intra-prediction mode used to generate the intra-predictionblock B may be an intra-prediction mode indicated by the first MPM indexof the MPM list. Alternatively, the intra-prediction mode used togenerate the intra-prediction block B may be an intra-prediction modehaving directionality among modes in the MPM list. In this case, whenthere are a plurality of modes having directionality in the MPM list,the intra-prediction block B may be generated using an intra-predictionmode having a smaller MPM index.

Thereafter, one or more template matching-based intermediateintra-prediction blocks may be generated using the generated template.

FIG. 25 is a diagram illustrating an embodiment for generating atemplate matching-based intermediate intra-prediction block on the basisof the MPM list.

The left table shown in FIG. 25 shows the MPM list for the currentblock. For example, the MPM list includes six candidate modes, eachcandidate mode being indicated by an index (MPM idx). In the embodimentshown in FIG. 25, the intra-prediction modes included in the MPM listare X, Y, N, Z, K, and L.

It is possible to generate a prediction block using each ofintra-prediction modes included in the MPM list. As shown in FIG. 25, aprediction block 0 is a prediction block corresponding to theintra-prediction mode X, and a prediction block 5 is a prediction blockcorresponding to the intra-prediction mode L. Likewise, although notshown in FIG. 25, prediction blocks 1 to 4 corresponding to theintra-prediction modes Y, N, Z, and K may also be generated.Hereinafter, the prediction block 0 to the prediction block 5 is definedas a prediction block n (n is one of 0 to 5).

Thereafter, template matching between a template and a prediction blockn generated by using modes included in the MPM list may be performed.The template matching may be performed by calculating at least one of asum of absolute differences (SAD) and/or a sum of absolute transformeddifferences (SATD) between the template and the prediction block n.Herein, the template matching may be omitted for a mode same as theintra-prediction mode (for example, N in FIG. 25) used for generatingthe template among the intra-prediction modes included in the MPM list.

As described above, after the template matching is performed for each ofintra-prediction modes included in the MPM list to calculate SAD_0 (orSARD_0) to SAD_5 (or SARD_5), a intra-prediction block having thesmallest SAD and/or SATD may be defined as an intermediateintra-prediction block. For example, when SAD_0 is the smallest, theprediction block 0 corresponding to the intra-prediction mode X may bean intermediate intra-picture block.

Alternatively, after the calculated SAD and/or SATD are arranged inincreasing order, M intra-prediction blocks in order of increasing SADand/or SATD may be defined as intermediate intra-prediction blocks.Herein, M is a positive integer equal to or greater than 1 and may beless than or equal to the maximum number of candidate modes configuringthe MPM list. For example, when the maximum number of candidate modesconfiguring the MPM list is 7, the maximum value of M may be defined as7.

The order of the intra-prediction modes in the MPM list may berearranged using at least one of the SAD and/or the SATD.

The above description of the template matching may be similarly appliedto the case of using a secondary MPM list instead of the MPM list.

That is, a prediction block may be generated using each ofintra-prediction modes included in the secondary MPM list. Thereafter,template matching between the template and the prediction blockgenerated using the mode included in the secondary MPM list may beperformed. The template matching may be performed by calculating atleast one of a sum of absolute differences (SAD) and/or a sum ofabsolute transformed differences (SATD) between the template and theprediction block. Herein, the template matching may be omitted for amode same as the intra-prediction mode used when generating the templateamong the intra-prediction modes included in the secondary MPM list.Then, an intra-prediction block having the smallest SAD and/or SATD maybe defined as an intermediate intra-prediction block. Alternatively, thecalculated SAD and/or SATD may be arranged in increasing order, and theM intra-prediction blocks in order of increasing SAD and/or SATD may bedefined as intermediate intra-prediction blocks. Here, M is a positiveinteger equal to or greater than 1 and may be less than or equal to themaximum number of candidate modes configuring a secondary MPM list. Forexample, when the maximum number of candidate modes configuring thesecondary MPM list is 16, the maximum value of M may be defined as 16.

The order of the intra-prediction modes in the secondary MPM list may berearranged using at least one of the SAD and/or the SATD.

In another embodiment, an intra-frame prediction block corresponding toan intra-prediction mode of at least one neighboring block in whichencoding/decoding is completed may be defined as an intermediateintra-prediction block. The neighboring blocks may be at least one ofthe neighboring blocks L, A, AR, BL, AL, JL, and JA shown in FIG. 11.

Alternatively, a predetermined statistical value may be obtained byusing one or more intra-prediction modes derived from one or moreneighboring blocks, and an intra-prediction block corresponding to thestatistical value may be defined as an intermediate intra-predictionblock. Herein, the statistical value may include at least one of anaverage value, a maximum value, a minimum value, an intermediate value,and a mode value. The statistical value may be calculated usingintra-prediction modes of all intra-predicted neighboring blocks shownin FIG. 11.

In another embodiment, when the number of intra-prediction modes usedwhen generating the template is N, a prediction block corresponding tothe intra-prediction mode in which a predetermined offset is addedand/or subtracted to and/or from N may be defined as an intermediateintra-prediction block. Herein, the offset may be a positive integer of1 or more.

After generating the template and at least one intermediateintra-prediction block as described above, the final intra-predictionblock for the current block may be generated using the template and atleast one intermediate intra-prediction block. Herein, a weighted summay be used.

FIG. 26 is a view illustrating an embodiment for generating a finalintra-prediction block using a template and one intermediateintra-prediction block.

As shown in FIG. 26, a final intra-prediction block may be generated byusing a weighted sum of a template and an intermediate intra-predictionblock.

FIG. 27 is a diagram illustrating an embodiment in which a finalintra-frame prediction block is generated using the template and aplurality of intermediate intra-prediction blocks.

As shown in FIG. 27, a final prediction block may be generated by usinga weighted sum of the template and the plurality of intermediateintra-prediction blocks.

In the embodiment described with reference to FIGS. 26 and 27, theweight for performing the weighted sum may be derived as follows.Herein, the sum of all the weights used in the weighted sum may be oneor not. In addition, each weight may be greater than or less than one.

For example, all weights used in the weighted sum may be the same.

Alternatively, different weights may be applied for each block accordingto a predetermined priority between the template and/or at least oneintermediate intra-prediction block.

For example, a higher weight may be applied to a template correspondingto a predetermined intra-prediction mode and/or an intermediateintra-prediction block, than an intra-prediction block corresponding tothe remaining modes. Conversely, a lower weight may be applied to thetemplate corresponding to the predetermined intra-prediction mode and/orthe intermediate intra-prediction block. For example, the predeterminedintra-prediction mode may be the first intra-prediction mode of the MPMlist. In this case, a relatively high weight may be given to theintra-prediction block corresponding to the first intra-prediction modein the MPM list.

When encoding a current block by using intra-prediction, the encoder maydetermine whether or not to perform the method proposed in the presentinvention and entropy-encode indication information indicating whetheror not to perform the method. Whether or not to perform the methodproposed in the present invention may be determined through a comparisonof a rate-distortion cost value before applying the proposed method anda rate-distortion cost value after application.

The indication information may be conditionally entropy-encodedaccording to coding parameter of the current block. For example, theindication information may be entropy-encoded only when theintra-prediction mode of the current block is encoded using a modeincluded in the MPM list and/or the secondary MPM list. The decoder mayentropy-decode the indication information from the bit stream and thenperform or not perform the method proposed in the present inventionaccording to the received information.

The indication information may be omitted according to the encodingparameter of the current block. For example, it may be determinedwhether or not to perform the proposed method on the basis of apredetermined size, a form and/or a depth of the current block. Forexample, the proposed method may be performed or not performed only whenthe current block is less than or equal to or equal to or greater thanthe predetermined size, form, or depth. Herein, the information on thepredetermined size, form, and/or depth may be entropy-encoded/decoded inunits of at least one of a video parameter set VPS, a sequence parameterset SPS, a picture parameter set PPS, a tile header, a slice header,CTU, and CU.

For example, when the size of the current block is less than or equal toa predetermined first size and/or equal to or greater than apredetermined second size, and the current block is divided into binarytree leaf nodes and/or quad tree leaf nodes, the proposed method may beperformed or may be not performed.

Alternatively, the proposed method may be performed when encoded using amode included in the MPM list and/or the secondary MPM list.

It may be determined whether or not to perform the proposed method onthe basis of a comparison of the size and depth of current block with apredetermined threshold value. In this case, the predetermined thresholdvalue may mean a reference size or depth for determining the blockstructure. The predetermined threshold may be expressed in at least oneof a minimum value and a maximum value. The predetermined thresholdvalue may be a fixed value predefined by the encoder/decoder, variablyderived on the basis of the encoding parameter of the current block, ormay be signaled through a bitstream.

For example, the proposed method may or may not be performed when thesize or depth of the current block is less than or equal to a firstpredetermined threshold value and/or equal to or greater than a secondpredetermined threshold value.

Alternatively, when a depth of the current block is equal to thepredetermined threshold value and the current block corresponds to aquad tree leaf node, the proposed method may not be performed.

In order to determine an encoding mode for the current block, an encoderperforms at least one of transform, quantization, entropy encoding,entropy decoding, dequantization, and inverse-transform on a residualsignal between the current block and the prediction block, and thendetermines an encoding mode so that the required bit amount and videoquality loss may be minimized. The determined encoding mode may beencoded as encoding mode information, and the encoding mode informationmay be used with the same meaning as an encoding parameter.

Assuming that the maximum number of candidate blocks in a merge modeand/or a skip mode for the current block is M, a process of determiningan encoding mode for the merge mode and/or the skip mode may beperformed only on merge modes and/or skip mode candidate blocks of thenumber that is equal to or less than M according to conditions describedbelow.

In the process of determining the encoding mode for the merge modeand/or the skip mode, when the current block (quad tree leaf node and/orbinary tree leaf node) is re-encoded by the encoder, in the case that itis determined as the skip mode in an initial encoding process, it ispossible to perform a skip mode encoding determination process forcandidate blocks in all merge modes and/or skip modes.

In the process of determining the encoding mode for the merge modeand/or the skip mode, when the current block (quad tree leaf node and/orbinary tree leaf node) is re-encoded by the encoder, when it isdetermined as the merge mode in the initial encoding process, it ispossible to perform a merge mode encoding determination process forcandidate blocks in all the merge modes and/or skip modes.

In the process of determining the encoding mode for the merge modeand/or the skip mode, when the current block (quad tree leaf node and/orbinary tree leaf node) is re-encoded by the encoder, when it isdetermined as the skip mode and/or the merge mode in the initialencoding process, it is possible to perform an overlapped block motioncompensation (OBMC) process in a motion compensation process forcandidate blocks in all merge modes and/or skip modes.

In the process of determining the encoding mode for the current block,the encoding mode determination process for the primary transform and/orthe secondary transform may be omitted according to the encodingparameter of the current block and/or the neighboring blocks that aretemporally/spatially adjacent to the current block.

For example, when it is assumed that the number of 1D transform kernelsthat may be used for the primary transform in the primary transform is Nat maximum, and thus the primary transform index (ucTrIdx) isentropy-encoded/decoded from 0 to N−1, if CBF for the current block is 0at index 0, the encoding mode determination process for subsequentindexes (ucTrIdx=1, . . . , N−1) may be omitted. Alternatively, theencoding mode determination process of the current block may beperformed only for the primary transform index used for the primarytransform of the neighboring blocks of the current block.

In the process of determining the intra-picture and/or inter-pictureencoding mode for the current block, when entropy-encoding the primarytransform index information (ucTrIdx) for the 1D transform kernel usedfor the primary transform, a division operation may be replaced with ashift operation.

In the process of determining the intra-picture encoding mode for thecurrent block, when entropy-encoding the primary transform indexinformation (ucTrIdx) for the 1D transform kernel used for the primarytransform, a division operation and/or a shift operation may be used.For example, the primary transform index information ucTrIdx may beentropy-encoded using a division operation as shown in Equation 19below.m_pcBinIf→encodeBin((ucTrIdx/2)?1:0,m_cEmtTuIdxSCModel,get(0,0,1));  [Equation19]

Alternatively, the primary transform index information ucTrIdx may beentropy-encoded using a shift operation as shown in Equation 20 below.m_pcBinIf→encodeBin((ucTrIdx>>1)?1:0,m_cEmtTuIdxSCModel.get(0,0,1));  [Equation20]

In the process of determining the inter-picture encoding mode for thecurrent block, when entropy-encoding the primary transform indexinformation (ucTrIdx) for the 1D transform kernel used for the primarytransform, the equations 19 and 20 may be used similarly. However, inthis case, get (0,0,1) may be replaced with get (0,0,3) in the equations19 and 20.

The residual signal generated after performing intra-prediction orinter-prediction may be converted into a frequency domain through atransform process as a part of a quantization process. In this case, aprimary transform may be used with various DCT kernels, DST kernels, andthe like in addition DCT type 2 (DCT-II). The transform using thetransform kernels may be performed by a separable transform in whichone-dimensional transform (1D transform) is performed on the horizontaland vertical directions of the residual signal, or by a two-dimensionalnon-separable transform (2D Non-separable Transform).

The DCT and DST types used in the transform are shown in Table 1 below.

TABLE 1 Transform set Transform 0 DCT-VII, DCT-VIII 1 DST-VII, DST-I 2DST-VII, DCT-V

In addition to DCT-II, at least one of DST-II, DCT-IV, DST-IV, DCT-VIII,and DST-VII may be adaptively used during 1D transform. Alternatively, atransform set may be configured to derive the DCT or DST type used inthe transform. For example, according to the intra-prediction mode,different transform sets may be pre-defined for horizontal and verticaldirections. The encoder/decoder may perform the transform andinverse-transform using the transform included in the transform setcorresponding to the intra-prediction mode of the current block. In thiscase, the transform set is not transmitted, but is mapped in theencoder/decoder according to the same rule as shown in Table 1, in whichinformation indicating which transform is used among the transformsbelonging to the transform set may be signaled. Such a method of usingvarious transforms may be applied to a residual signal generated throughintra-prediction or inter-prediction. For example, during inter-pictureprediction, the encoder/decoder may perform 1D transform on the verticaland/or horizontal directions using the transform set 0 of Table 1. Inthis case, information indicating which 1D transform is used for thevertical and/or horizontal directions may be entropy-encoded/decoded.Further, information indicating which one of DST-II, DCT-IV, DST-IV,DCT-VIII and DST-VII is used for the vertical and/or horizontaldirectional transform may be entropy-encoded/decoded. After theabove-described primary transform is completed, the encoder may performa secondary transform to increase the energy concentration on transformcoefficients as shown in FIG. 6. The secondary transform may alsoperform a separable transform that performs one dimensional transformfor each of the horizontal and vertical directions, or may perform atwo-dimensional non-separable transform. In addition, the informationused for the transform may be transmitted or implicitly derived by theencoder/decoder according to the encoding information of the currentblock and the neighboring block. For example, a transform set may bedefined for the secondary transform, like the first transform, and thetransform set may be not entropy-encoded/decoded, but defined accordingto the same rules by the encoder/decoder. In this case, informationindicating which transform is used among transforms belonging to thetransform set may be transmitted and may be applied to at least one ofresidual signals generated through intra-prediction or inter-prediction.The decoder may perform the secondary inverse-transform according towhether or not the secondary inverse-transformation is performed, andperform the primary inverse-transformation on the result of performingthe secondary inverse-transform on a result obtained by performing thesecondary inverse-transform according to whether or not the primaryinverse-transform is performed.

The primary transform and the secondary transform may be applied to atleast one signal component of luma/chroma components or may beadaptively applied according to an arbitrary encoding block size/from.Whether or not the primary transform and the secondary transform areused for an arbitrary encoding block and the index indicating the usedprimary transform and/or secondary transform may beentropy-encoded/decoded or implicitly derived by the encoder/decoderaccording to at least one of encoding information of the current blockand the neighboring block.

FIG. 28 is a diagram illustrating a method of scanning a transformcoefficient.

For the residual signal generated through intra-prediction orinter-prediction, the primary and secondary transforms are performed,and then quantization process is performed, in which an entropy encodingprocess may be performed on the quantized transform coefficients. Inthis case, as shown in FIG. 28, the quantized transform coefficients maybe scanned according to a diagonal direction, a vertical direction, or ahorizontal direction on the basis of at least one of an intra-predictionmode of the current block and a minimum size and/or form of the encodingblock. In addition, the entropy-decoded quantized transform coefficientsmay be inverse-scanned and arranged in a block form, and at least one ofinverse-quantization and inverse-transform may be performed on thecorresponding block. Herein, at least one of diagonal scan, horizontalscan, and vertical scan shown in FIG. 28 may be performed as theinverse-scanning method.

When performing intra or inter prediction, a first color component mayundergo intra prediction and a second color component may undergo interprediction. For example, the first color component is a luminancecomponent, and the second color component is a chrominance component.Conversely, the first color component may be a chrominance component andthe second color component may be a luminance component.

Regarding application of filtering to the prediction samples, whether toapply filtering or not may be determined depending on at least one ofthe intra prediction mode, size (width and height), block shape,multiple sample line-based prediction, and color component of thecurrent block. The filtering refers to a method of filtering one or moreprediction samples using one or more reference samples.

For example, when the intra prediction mode of the current block is apredetermined mode, the filtering may be applied to the predictionsamples. For example, the predetermined mode is a directional mode, anon-directional, a horizontal mode, or a vertical mode.

For example, when the size of the current block falls within apredetermined size range, the filtering may be applied to the predictionsamples. For example, when the current block has a width less than 64and a height less than 64, the filtering may be applied. Alternatively,when the width or height of the current block is larger or smaller thana predetermined size, the filtering may be applied.

For example, whether to apply filtering to the prediction samples may bedetermined depending on the reference sample line used for theprediction. For example, when the reference sample line used for theprediction is the first reference sample line adjacent to the currentblock, the filtering may be applied. On the other hand, when thereference sample line is one of the second and onward reference samplelines positioned around the current block, the filtering may not beapplied. The indicator mrl_index may be used to determine the referencesample line. For example, when the index for the current block is zero,the filtering is applied. However, when the index for the current blockis a value greater than zero, the filtering is not applied.

For example, when the color component of the block element is aluminance signal, the filtering is applied. However, when the colorcomponent of the current block is a chrominance signal, the filtering isnot applied.

The prediction for the current block can be performed by combining oneor more exemplary prediction methods described above.

For example, the prediction for the current block may be performed bycalculating the weighted sum of a prediction value obtained using apredetermined non-directional intra prediction mode and a predictionvalue obtained using a predetermined directional intra prediction mode.In this case, the weights may vary depending on at least one of theintra prediction mode of the current block, the size/shape of thecurrent block, and the position of the prediction target sample.

For example, the prediction for the current may be performed bycalculating the weighted sum of a prediction value obtained using apredetermined intra prediction mode and a prediction value obtainedpredicted using a predetermined inter prediction mode. In this case, theweights may vary depending on at least one of the encoding mode, theintra prediction mode, the inter prediction mode, and the size/shape ofthe current block. For example, when the intra prediction mode is anon-directional mode such as DC or Planar, a weight corresponding to ½may be applied to an intra prediction sample and an inter predictionsample, respectively. Alternatively, when the intra prediction mode is avertical mode, the weight for the intra prediction sample decreases withdistance from the reference sample line above the current block.Similarly, when the intra prediction mode is a horizontal mode, theweight for the intra sample decreases with distance from the referencesample line on the left side of the current block. The sum of the weightapplied to the intra prediction sample and the weight applied to theinter prediction sample may be any one of the powers of two. That is, itmay be any of 4, 8, 16, 32, and so forth. For example, when the size ofthe current block is within a predetermined size range, a weightcorresponding to ½ may be applied to the intra prediction sample and theinter prediction sample, respectively.

The intra prediction mode may be fixed to DC mode and Planar mode, ormay be determined through signaling of information. Alternatively, theintra prediction mode may be any mode selected from among MPM candidatemodes, and may be determined through The MPM candidate modes are derivedfrom the intra prediction modes of neighboring blocks. The mode of theneighboring block can be replaced with a predetermined representativemode. For example, the intra prediction mode of a neighboring block is adirectional mode of a specific direction categorized into a verticaldirection group, the mode of the neighboring block is replaced with thevertical mode. On the other hand, when the intra prediction mode of aneighboring block is a directional mode of a specific directioncategorized into a horizontal direction group, the mode of theneighboring block is replaced with the horizontal mode.

The inter prediction may be at least one of DC mode, merge mode, andAMVP mode. When the inter prediction mode of the current block is mergemode, the prediction for the current block may be performed bycalculating the weighted sum of the inter prediction value obtained byusing motion information corresponding to a merge index and theprediction value obtained by using DC or Planar mode.

For example, the prediction for the current block may be performed bycalculating the weighted sum of one or more prediction samples obtainedby using multiple sample lines. For example, the prediction may beperformed by calculating the weighted sum of a first prediction valueobtained by using the first reference sample line near the current blockand a second prediction value obtained by using the second and onwardreference sample lines near the current block. The reference samplelines used to obtain the second prediction value may be reference samplelines indicated by mrl_index. The weights for the first prediction valueand the second prediction value may be equal. Alternatively, the weightsfor the first prediction value and the second prediction value may varydepending on at least one of the intra prediction mode of the currentblock, the size/shape of the current block, and the position of thesample to be prediction. The first prediction value may be a valuepredicted using a predetermined mode. For example, the first predictionvalue may be a value predicted using at least one of DC mode and Planarmode. The second prediction value may be a value predicted using theintra prediction mode of the current block, which is derived in theavailable intra prediction mode derivation step.

When prediction is performed by calculating the weighted sum of one ormore prediction samples, filtering may not be performed on theprediction samples.

The above embodiments may be performed in the same method in an encoderand a decoder.

A sequence of applying to above embodiment may be different between anencoder and a decoder, or the sequence applying to above embodiment maybe the same in the encoder and the decoder.

The above embodiment may be performed on each luma signal and chromasignal, or the above embodiment may be identically performed on luma andchroma signals.

A block form to which the above embodiments of the present invention areapplied may have a square form or a non-square form.

The above embodiment of the present invention may be applied dependingon a size of at least one of a coding block, a prediction block, atransform block, a block, a current block, a coding unit, a predictionunit, a transform unit, a unit, and a current unit. Herein, the size maybe defined as a minimum size or maximum size or both so that the aboveembodiments are applied, or may be defined as a fixed size to which theabove embodiment is applied. In addition, in the above embodiments, afirst embodiment may be applied to a first size, and a second embodimentmay be applied to a second size. In other words, the above embodimentsmay be applied in combination depending on a size. In addition, theabove embodiments may be applied when a size is equal to or greater thata minimum size and equal to or smaller than a maximum size. In otherwords, the above embodiments may be applied when a block size isincluded within a certain range.

For example, the above embodiments may be applied when a size of currentblock is 8×8 or greater. For example, the above embodiments may beapplied when a size of current block is 4×4 or greater. For example, theabove embodiments may be applied when a size of current block is equalto or less than 16×16. For example, the above embodiments may be appliedwhen a size of current block is equal to or greater than 16×16 and equalto or smaller than 64×64.

The above embodiments of the present invention may be applied dependingon a temporal layer. In order to identify a temporal layer to which theabove embodiments may be applied, a corresponding identifier may besignaled, and the above embodiments may be applied to a specifiedtemporal layer identified by the corresponding identifier. Herein, theidentifier may be defined as the lowest layer or the highest layer orboth to which the above embodiment may be applied, or may be defined toindicate a specific layer to which the embodiment is applied. Inaddition, a fixed temporal layer to which the embodiment is applied maybe defined.

For example, the above embodiments may be applied when a temporal layerof a current image is the lowest layer. For example, the aboveembodiments may be applied when a temporal layer identifier of a currentimage is 1. For example, the above embodiments may be applied when atemporal layer of a current image is the highest layer.

A slice type to which the above embodiments of the present invention areapplied may be defined, and the above embodiments may be applieddepending on the corresponding slice type.

In the above-described embodiments, the methods are described based onthe flowcharts with a series of steps or units, but the presentinvention is not limited to the order of the steps, and rather, somesteps may be performed simultaneously or in different order with othersteps. In addition, it should be appreciated by one of ordinary skill inthe art that the steps in the flowcharts do not exclude each other andthat other steps may be added to the flowcharts or some of the steps maybe deleted from the flowcharts without influencing the scope of thepresent invention.

The embodiments include various aspects of examples. All possiblecombinations for various aspects may not be described, but those skilledin the art will be able to recognize different combinations.Accordingly, the present invention may include all replacements,modifications, and changes within the scope of the claims.

The embodiments of the present invention may be implemented in a form ofprogram instructions, which are executable by various computercomponents, and recorded in a computer-readable recording medium. Thecomputer-readable recording medium may include stand-alone or acombination of program instructions, data files, data structures, etc.The program instructions recorded in the computer-readable recordingmedium may be specially designed and constructed for the presentinvention, or well-known to a person of ordinary skilled in computersoftware technology field. Examples of the computer-readable recordingmedium include magnetic recording media such as hard disks, floppydisks, and magnetic tapes; optical data storage media such as CD-ROMs orDVD-ROMs; magneto-optimum media such as floptical disks; and hardwaredevices, such as read-only memory (ROM), random-access memory (RAM),flash memory, etc., which are particularly structured to store andimplement the program instruction. Examples of the program instructionsinclude not only a mechanical language code formatted by a compiler butalso a high level language code that may be implemented by a computerusing an interpreter. The hardware devices may be configured to beoperated by one or more software modules or vice versa to conduct theprocesses according to the present invention.

Although the present invention has been described in terms of specificitems such as detailed elements as well as the limited embodiments andthe drawings, they are only provided to help more general understandingof the invention, and the present invention is not limited to the aboveembodiments. It will be appreciated by those skilled in the art to whichthe present invention performs that various modifications and changesmay be made from the above description.

Therefore, the spirit of the present invention shall not be limited tothe above-described embodiments, and the entire scope of the appendedclaims and their equivalents will fall within the scope and spirit ofthe invention.

INDUSTRIAL APPLICABILITY

The present invention may be used in encoding/decoding an image.

The invention claimed is:
 1. An image decoding method performed by animage decoding apparatus, comprising: determining whether to generate aprediction block of a current block based on combining of a firstprediction block and a second prediction block for the current block;generating, based on the determination, the first prediction block byinter-prediction based on first motion information and the secondprediction block by inter-prediction based on second motion information;determining a partitioning shape for combining the first predictionblock and the second prediction block; and generating the predictionblock of the current block by combining the first prediction block andthe second prediction block based on the partitioning shape, wherein thepartitioning shape is determined based on a partition angle and apartition location that are indicated by a partition index from abitstream, the partitioning index indicates a pair of the partitionangle and the partition location among partition candidates in apredetermined partition candidate set, the partition angle comprising aplurality of diagonal directions.
 2. The method of claim 1, wherein theprediction block of the current block is generated by weighted summingthe plurality of prediction blocks.
 3. The method of claim 2, whereinweights used for the weighted summing of the plurality of predictionblocks are different for each of the plurality of prediction blocks. 4.The method of claim 1, wherein the determining whether to generate theprediction block of the current block based on combining of the firstprediction block and the second prediction block is performed based onan encoding parameter of the current block.
 5. The method of claim 1,wherein the determining whether to generate the prediction block of thecurrent block based on combining of the first prediction block and thesecond prediction block is performed based on at least one among a sizeof the current block, a slice type of a slice to which the current blockbelongs and a prediction mode of the current block.
 6. The method ofclaim 1, wherein the partitioning index is decoded in a fixed length. 7.The method of claim 1, wherein the first prediction block is differentfrom the second prediction block.
 8. An image encoding method performedby an image encoding apparatus, comprising: determining whether togenerate a prediction block of a current block based on combining of afirst prediction block and a second prediction block for the currentblock; generating, based on the determination, the first predictionblock by inter-prediction based on first motion information and thesecond prediction block by inter-prediction based on second motioninformation; determining a partitioning shape for combining the firstprediction block and the second prediction block; and generating theprediction block of the current block by combining the first predictionblock and the second prediction block based on the partitioning shape,wherein the partitioning shape is determined based on a partition angleand a partition location that are indicated by a partition index from abitstream, the partitioning index indicates a pair of the partitionangle and the partition location among partition candidates in apredetermined partition candidate set, the partition angle comprising aplurality of diagonal directions.
 9. The method of claim 8, wherein theprediction block of the current block is generated by weighted summingthe plurality of prediction blocks.
 10. The method of claim 9, whereinweights used for the weighted summing of the plurality of predictionblocks are different for each of the plurality of prediction blocks. 11.The method of claim 8, wherein the determining whether to generate theprediction block of the current block based on combining of the firstprediction block and the second prediction block is performed based onat least one among a size of the current block, a slice type of a sliceto which the current block belongs and a prediction mode of the currentblock.
 12. The method of claim 8, wherein the partitioning index isencoded in a fixed length.
 13. The method of claim 8, wherein the firstprediction block is different from the second prediction block.
 14. Anon-transitory computer readable recording medium storing a bitstreamthat is generated by an image encoding method performed by an imageencoding apparatus, the image encoding method comprising: determiningwhether to generate a prediction block of a current block based oncombining of a first prediction block and a second prediction block forthe current block; generating, based on the determination, the firstprediction block by inter-prediction based on first motion informationand the second prediction block by inter-prediction based on secondmotion information; determining a partitioning shape for combining thefirst prediction block and the second prediction block; and generatingthe prediction block of the current block by combining the firstprediction block and the second prediction block based on thepartitioning shape, wherein the partitioning shape is determined basedon a partition angle and a partition location that are indicated by apartition index from a bitstream, the partitioning index indicates apair of the partition angle and the partition location among partitioncandidates in a predetermined partition candidate set, the partitionangle comprising a plurality of diagonal directions.